-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
45 lines (41 loc) · 1.47 KB
/
script.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
window.onload = () => {
let toggle = false;
let blackSquare = document.getElementById("black");
blackSquare.addEventListener('click', () => {
// setTimeout( () => {
blackSquare.style.animation = 'move-black 10s linear';
// }, 200);
blackSquare.classList.add('avoid-clicks')
setTimeout(() => {
blackSquare.classList.remove('avoid-clicks')
}, 10000)
});
let greenSquare = document.getElementById("green");
greenSquare.addEventListener('click', () => {
// setTimeout(() => {
greenSquare.style.animation = 'move-green 10s linear';
// }, 200);
greenSquare.classList.add('avoid-clicks')
setTimeout(() => {
greenSquare.classList.remove('avoid-clicks')
}, 10000)
});
let redSquare = document.getElementById("red");
redSquare.addEventListener('click', () =>{
// setTimeout(() => {
toggle = !toggle;
if(!toggle){
console.log()
redSquare.classList.remove('move-red-first');
redSquare.classList.add('move-red-second');
}else {
redSquare.classList.remove('move-red-second');
redSquare.classList.add('move-red-first');
}
redSquare.classList.add('avoid-clicks')
setTimeout(() => {
redSquare.classList.remove('avoid-clicks')
}, 10000)
// }, 200);
})
}