-
Notifications
You must be signed in to change notification settings - Fork 0
/
animate.js
86 lines (77 loc) · 1.87 KB
/
animate.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const logoBtn = document.getElementById('logo-brand');
const originalScale = 1;
const whileTapScale = 0.8;
logoBtn.addEventListener('mousedown', function () {
gsap.to(this, {
scale: whileTapScale,
duration: 0.2,
ease: "power4.out"
});
});
logoBtn.addEventListener('mouseup', function () {
gsap.to(this, {
scale: originalScale,
duration: 0.2,
ease: "power4.out"
});
});
logoBtn.addEventListener('mouseout', function () {
gsap.to(this, {
scale: originalScale,
duration: 0.2,
ease: "power4.out"
});
});
const loadingAnimation = () => {
const tl = gsap.timeline({
onComplete: () => {
maskAnimation();
}
});
tl
.from(
"#loading-page svg",
{
scale: 0,
duration: 1,
ease: "elastic.out(1, 0.75)"
},
0
)
.to("#loading-page", {
yPercent: -100,
duration: 1,
delay: .4,
ease: "power2.inOut"
})
};
gsap.registerPlugin(ScrollTrigger);
const maskAnimation = () => {
const masks = document.querySelectorAll('.mask');
masks.forEach(mask => {
const image = mask.querySelector('img');
const tl = gsap.timeline({
scrollTrigger: {
trigger: mask,
toggleActions: "restart none none reset"
}
});
tl.set(mask, { autoAlpha: 1 });
tl.from(mask, {
y: 80,
stagger: {
each: 1,
ease: "power2.inOut"
}
});
tl.from(image, {
scale: 1.1,
transformOrigin: 'top',
stagger: {
each: 0.3,
ease: "power2.out"
},
}, '<0.2');
});
};
loadingAnimation();