-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
161 lines (145 loc) · 3.16 KB
/
script.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
let menu = document.querySelector("#menu-btn");
let navbar = document.querySelector(".navbar");
menu.onclick = () => {
menu.classList.toggle("fa-times");
navbar.classList.toggle("active");
};
window.onscroll = () => {
menu.classList.remove("fa-times");
navbar.classList.remove("active");
};
let tween = gsap.to(".title", {
rotation: 0,
y: 0,
duration: 2,
opacity: 1,
startAt: { y: -300, opacity: 0 },
ease: "bounce.out",
});
// smoothscroll used from : https://github.com/darkroomengineering/lenis
const lenis = new Lenis();
lenis.on("scroll", (e) => {
console.log(e);
});
function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
// end
document.addEventListener("DOMContentLoaded", function () {
const mm = gsap.matchMedia();
mm.add("(min-width: 990px)", () => {
// Animations for entry1 and entry2
gsap.to(".entry1", {
startAt: { y: -200, opacity: 0 },
y: 0,
x: 0,
duration: 2,
opacity: 1,
});
gsap.to(".entry2", {
startAt: { y: 200, opacity: 0 },
y: 0,
x: 0,
duration: 2,
opacity: 1,
});
// Animations for heading sections
gsap.to(".headingentry-section2", {
scrollTrigger: ".headingentry-section2",
startAt: { x: -200, opacity: 0 },
x: 0,
duration: 1,
opacity: 1,
});
gsap.to(".headingentry-section3", {
scrollTrigger: ".headingentry-section3",
startAt: { x: -200, opacity: 0 },
x: 0,
duration: 1,
opacity: 1,
});
gsap.to(".headingentry-section4", {
scrollTrigger: ".headingentry-section4",
startAt: { x: -200, opacity: 0 },
x: 0,
duration: 1,
opacity: 1,
});
// Animations for reveal-on-scroll elements
gsap.to(".reveal-on-scroll", {
scrollTrigger: ".reveal-on-scroll",
startAt: { x: 0, opacity: 0 },
x: 0,
duration: 3,
opacity: 1,
});
gsap.to(".reveal-on-scroll-2", {
scrollTrigger: ".reveal-on-scroll-1",
startAt: { x: 0, opacity: 0 },
x: 0,
duration: 4,
opacity: 1,
});
// Animations for section3
gsap.to(".section3-box1", {
scrollTrigger: ".section3-box1",
startAt: { x: -500, opacity: 0 },
x: 0,
duration: 2,
opacity: 1,
});
gsap.to(".section3-box2", {
scrollTrigger: ".section3-box2",
startAt: { x: 500, opacity: 0 },
x: 0,
duration: 2,
opacity: 1,
});
// Animations for section4
gsap.to(".section4-box1", {
scrollTrigger: ".section4-box2",
startAt: { x: -500, opacity: 0 },
x: 0,
duration: 4,
opacity: 1,
});
gsap.to(".section4-box2", {
scrollTrigger: ".section4-box2",
startAt: { x: -500, opacity: 0 },
x: 0,
duration: 3,
opacity: 1,
});
gsap.to(".section4-box3", {
scrollTrigger: ".section4-box3",
startAt: { x: -500, opacity: 0 },
x: 0,
duration: 2,
opacity: 1,
});
gsap.to(".section4-box4", {
scrollTrigger: ".section4-box4",
startAt: { x: -500, opacity: 0 },
x: 0,
duration: 1,
opacity: 1,
});
// Animation for stagger1 in section5
gsap.to(".stagger1", {
startAt: { y: +100, opacity: 0 },
scrollTrigger: ".stagger1",
duration: 1,
scale: 1,
y: 0,
ease: "power1.inOut",
stagger: {
grid: [20, 15],
from: "random",
amount: 1,
},
opacity: 1,
});
});
});