-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
61 lines (52 loc) · 1.39 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const intro = document.querySelector('.intro');
const video = intro.querySelector('video');
const titulo = intro.querySelector('.titulo');
const rendimiento = intro.querySelector('.rendimiento');
//END SECTION
const section = document.querySelector('section');
const end = section.querySelector('h1');
//SCROLL MAGIC
const controller = new ScrollMagic.Controller();
//Escena
let scene = new ScrollMagic.Scene({
duration: 26000, //Duracion del video en ms
triggerElement: intro,
triggerHook: 0
})
.setPin(intro)
.addTo(controller);
//titulo animation
let tituloAnim = TweenMax.fromTo(titulo, 3, { opacity: 1 }, { opacity: 0 });
let sceneTitulo = new ScrollMagic.Scene({
duration: 3000,
triggerElement: intro,
triggerHook: 0
})
.setTween(tituloAnim)
.addTo(controller);
//Animacion ON rendimiento
let rendimientoAnim = TweenMax.fromTo(
rendimiento,
3,
{ opacity: 0 },
{ opacity: 1 }
);
let sceneRendimiento = new ScrollMagic.Scene({
duration: 1000,
triggerElement: intro,
triggerHook: 0
})
.offset(3000)
.setTween(rendimientoAnim)
.addTo(controller);
//Animacion del video
let accelamount = 0.1;
let scrollpos = 0;
let delay = 0;
scene.on('update', e => {
scrollpos = e.scrollPos / 1000; //Para sacar los segundos por los que deberia ir el video
});
setInterval(() => {
delay += (scrollpos - delay) * accelamount;
video.currentTime = delay;
}, 100); // 1000/30 => 1 segundo entre los 30 fps