-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
46 lines (40 loc) · 1.4 KB
/
main.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
46
const $disc = document.getElementById("disc");
const $play = document.getElementById("play");
const $pause = document.getElementById("pause");
const $stop = document.getElementById("stop");
const $reverse = document.getElementById("reverse");
//When clic on play button
$play.addEventListener("click", (event)=> {
animation.play(); //Existing method in animation
});
//When clic on pause button
$pause.addEventListener("click", (event)=> {
animation.pause(); //Existing method in animation
});
//When clic on stop button
$stop.addEventListener("click", (event)=> {
animation.cancel(); //Existing method in animation
});
//When clic on reverse button
$reverse.addEventListener("click", (event)=> {
animation.reverse(); //Existing method in animation
});
//Animation of disc
const animation = $disc.animate([
//from
{
transform: 'rotate(0)'
},
//to
{
transform: 'rotate(360deg)'
}
], {
duration: 2000,
delay: 100,
direction: 'normal',
easing: 'linear',
iterations: 100,
});
//Initial state of animation
animation.pause();