-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
25 lines (19 loc) · 946 Bytes
/
app.js
File metadata and controls
25 lines (19 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const emojiPath = 'assets/frog.png';
const animatedEmojiPath = 'assets/frog.gif';
const emoji = document.querySelector('img');
const toggleDisabledButtons = () => {
startEmojiAnimationButton.classList.toggle('disabled');
startEmojiAnimationButton.disabled = !startEmojiAnimationButton.disabled;
stopEmojiAnimationButton.classList.toggle('disabled');
stopEmojiAnimationButton.disabled = !stopEmojiAnimationButton.disabled;
}
const changeEmojiSource = (path) => {
emoji.src = path;
toggleDisabledButtons();
}
const startEmojiAnimationButton = document.querySelector('.animate-start');
startEmojiAnimationButton.disabled = false;
startEmojiAnimationButton.addEventListener('click', () => changeEmojiSource(animatedEmojiPath));
const stopEmojiAnimationButton = document.querySelector('.animate-stop');
stopEmojiAnimationButton.disabled = true;
stopEmojiAnimationButton.addEventListener('click', () => changeEmojiSource(emojiPath));