-
Notifications
You must be signed in to change notification settings - Fork 0
/
liquify.js
59 lines (54 loc) · 1.46 KB
/
liquify.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
const liquifyTrigger = document.querySelector('.js-liquify-trigger');
const textTriggers = [...document.querySelectorAll('p')];
const inkTriggers = [...document.querySelectorAll('.js-ink-trigger')];
const controller = new ScrollMagic.Controller();
const sceneAuthorLiquid = new ScrollMagic.Scene({
triggerElement: liquifyTrigger,
triggerHook: 'onEnter',
})
.setTween('#liquid', 2, {
attr: {
scale: '0'
},
ease: Power4.easeOut,
delay: 3,
})
.reverse(false)
.addTo(controller);
const sceneAuthorTransition = new ScrollMagic.Scene({
triggerElement: liquifyTrigger,
triggerHook: 'onEnter',
})
.setTween(liquifyTrigger, 3, {
opacity: 1,
y: 1,
ease: Power4.easeOut,
delay: 1,
})
.reverse(false)
.addTo(controller);
textTriggers.map(text => {
const isBelowScreen = (text.getBoundingClientRect().top > window.innerHeight) ? true : false;
const dataDealy = (text.getAttribute('data-delay') === null || isBelowScreen) ? 0.5 : text.getAttribute('data-delay');
const sceneText = new ScrollMagic.Scene({
triggerElement: text,
triggerHook: 'onEnter',
})
.setTween(text, 1.5, {
y: 0,
opacity: 1,
ease: Power4.easeOut,
delay: dataDealy,
})
.reverse(false)
.addTo(controller);
});
inkTriggers.map(ink => {
const sceneInk = new ScrollMagic.Scene({
triggerElement: ink,
triggerHook: 'onEnter',
})
.setClassToggle(ink, 'is-active')
.reverse(false)
.addTo(controller);
});