-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (36 loc) · 1.05 KB
/
app.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
const intro = document.querySelector('.intro');
let video = intro.querySelector('video');
const text = intro.querySelector('h1');
const section = document.querySelector('section');
const end = section.querySelector('h1');
// ScrollMagic:
const controller = new ScrollMagic.Controller();
// with this scene I make te video to be pinned until I get to the button (duration)
let scene = new ScrollMagic.Scene({
duration: 20000,
triggerElement: intro,
triggerHook: 0
})
.setPin(intro)
.addTo(controller);
const textAnimation = TweenMax.fromTo(text, 5, {opacity: 1}, {opacity: 0});
let textScene = new ScrollMagic.Scene(
{
duration: 5000,
triggerElement: intro,
triggerHook: 0
}
)
.setTween(textAnimation)
.addTo(controller);
// Video Animation
let accelAmount = 0.1;
let scrollPos = 0;
let delay = 0;
scene.on("update", e => {
scrollPos = e.scrollPos / 1000; // divide to 1000 to have seconds
});
setInterval(() => {
delay += (scrollPos - delay) * accelAmount;
video.currentTime = delay;
}, 33.3);