-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
59 lines (54 loc) · 1.3 KB
/
script.js
File metadata and controls
59 lines (54 loc) · 1.3 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
const btn = document.querySelector("button#play");
const prg = document.querySelector("#prg");
const audio = document.querySelector("audio");
const pause = document.querySelector("#pause");
const tl = new gsap.timeline({paused: true, onReverseComplete: function(){
btn.style.pointerEvents = "initial";
btn.textContent = "Play Now";
}});
tl
.to(".lnk", {
y: -20,
stagger: .1,
opacity: 0,
duration: 1,
ease: Expo.easeInOut
})
.to(".shift", {
y: -80,
duration: 1.4,
ease: Expo.easeInOut,
onComplete: function(){
btn.style.pointerEvents = "none"
}
}, '-=.7')
.to("#player", {
bottom: 0,
duration: 1.4,
ease: Expo.easeInOut
}, '-=.7')
.to("#pause", {
y: -20,
opacity: 1,
duration: 2,
ease: Expo.easeInOut,
onComplete: function(){
pause.style.pointerEvents = "initial";
}
}, '-=.7')
btn.addEventListener("click", function(){
tl.play();
btn.textContent = "PLaying";
audio.play();
});
pause.addEventListener("click", function(){
audio.pause();
audio.currentTime = 0;
tl.reverse();
});
audio.addEventListener("timeupdate", function(){
var currentTime = audio.currentTime;
var duration = audio.duration;
var percent = (currentTime + .25) / duration * 100 + '%';
prg.style.width = percent;
})