-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
252 lines (220 loc) · 7.14 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// the locomotive scroll hijacks the scroll effect of gsap
// so we'll use locomotive with ScrollTrigger which is incorporated below in the init function
// function
function init(){
gsap.registerPlugin(ScrollTrigger);
const locoScroll = new LocomotiveScroll({
el: document.querySelector(".main"),
smooth: true
});
locoScroll.on("scroll", ScrollTrigger.update);
ScrollTrigger.scrollerProxy(".main", {
scrollTop(value) {
return arguments.length ? locoScroll.scrollTo(value, 0, 0) : locoScroll.scroll.instance.scroll.y;
}, // we don't have to define a scrollLeft because we're only scrolling vertically.
getBoundingClientRect() {
return { top: 0, left: 0, width: window.innerWidth, height: window.innerHeight };
},
pinType: document.querySelector(".main").style.transform ? "transform" : "fixed"
});
ScrollTrigger.addEventListener("refresh", () => locoScroll.update());
ScrollTrigger.refresh();
}
// function calling
init()
// cursor movement on document
var cursor = document.querySelector(".cursor");
document.addEventListener("mousemove", function(dets){
gsap.to(cursor, {
top: dets.clientY,
left: dets.clientX
});
});
// cursor movement on video of page1
var vid = document.querySelector(".page1 video");
var textHere = document.createTextNode("SOUND ON");
vid.addEventListener("mouseenter", function(){
cursor.style.width = "94px",
cursor.style.height = "25px",
cursor.style.borderRadius = "20px",
cursor.style.color = "#000",
cursor.appendChild(textHere),
cursor.style.fontSize = "90%",
cursor.style.padding = "5px 8px",
vid.style.cursor = "pointer"
})
vid.addEventListener("mouseleave", function(){
cursor.style.borderRadius = "50%",
cursor.style.border = "none",
cursor.style.width = "15px",
cursor.style.height = "15px",
cursor.style.backgroundColor = "#fff",
cursor.removeChild(textHere)
})
// cursor movement on page3
var textP3 = document.createTextNode("View");
// cursor movement on videos and images of page3 top container
var vid1P3 = document.querySelector("#page3containertop video");
var img1P3 = document.querySelector("#page3containertop img");
vid1P3.addEventListener("mouseenter", function(){
cursor.style.width = "50px",
cursor.style.height = "25px",
cursor.style.borderRadius = "30px",
cursor.style.fontSize = "15px",
cursor.style.padding = "6px 7px",
cursor.style.color = "#000",
cursor.appendChild(textP3),
vid1P3.style.cursor = "pointer",
vid1P3.style.filter = "blur(3px)",
img2P3.style.transition = "all ease 1s"
})
vid1P3.addEventListener("mouseleave", function(){
cursor.style.borderRadius = "50%",
cursor.style.border = "none",
cursor.style.width = "15px",
cursor.style.height = "15px",
cursor.style.backgroundColor = "#fff",
cursor.removeChild(textP3),
vid1P3.style.filter = "blur(0)",
vid1P3.style.transition = "all ease 1s"
})
img1P3.addEventListener("mouseenter", function(){
cursor.style.width = "50px",
cursor.style.height = "25px",
cursor.style.borderRadius = "30px",
cursor.style.fontSize = "15px",
cursor.style.padding = "6px 7px",
cursor.style.color = "#000",
cursor.appendChild(textP3),
img1P3.style.cursor = "pointer",
img1P3.style.filter = "blur(3px)",
img2P3.style.transition = "all ease 1s"
})
img1P3.addEventListener("mouseleave", function(){
cursor.style.borderRadius = "50%",
cursor.style.border = "none",
cursor.style.width = "15px",
cursor.style.height = "15px",
cursor.style.backgroundColor = "#fff",
cursor.removeChild(textP3),
img1P3.style.filter = "blur(0)",
img1P3.style.transition = "all ease 1s"
})
// cursor movement on videos and images of page3 bottom container
var vid2P3 = document.querySelector("#page3containerbottom video");
var img2P3 = document.querySelector("#page3containerbottom img");
vid2P3.addEventListener("mouseenter", function(){
cursor.style.width = "50px",
cursor.style.height = "25px",
cursor.style.borderRadius = "30px",
cursor.style.fontSize = "15px",
cursor.style.padding = "6px 7px",
cursor.style.color = "#000",
cursor.appendChild(textP3),
vid2P3.style.cursor = "pointer",
vid2P3.style.filter = "blur(3px)",
img2P3.style.transition = "all ease 1s"
})
vid2P3.addEventListener("mouseleave", function(){
cursor.style.borderRadius = "50%",
cursor.style.border = "none",
cursor.style.width = "15px",
cursor.style.height = "15px",
cursor.style.backgroundColor = "#fff",
cursor.removeChild(textP3),
vid2P3.style.filter = "blur(0)",
vid2P3.style.transition = "all ease 1s"
})
img2P3.addEventListener("mouseenter", function(){
cursor.style.width = "50px",
cursor.style.height = "25px",
cursor.style.borderRadius = "30px",
cursor.style.fontSize = "15px",
cursor.style.padding = "6px 7px",
cursor.style.color = "#000",
cursor.appendChild(textP3),
img2P3.style.cursor = "pointer",
img2P3.style.filter = "blur(3px)",
img2P3.style.transition = "all ease 1s"
})
img2P3.addEventListener("mouseleave", function(){
cursor.style.borderRadius = "50%",
cursor.style.border = "none",
cursor.style.width = "15px",
cursor.style.height = "15px",
cursor.style.backgroundColor = "#fff",
cursor.removeChild(textP3),
img2P3.style.filter = "blur(0)",
img2P3.style.transition = "all ease 1s"
})
// used gsap for animations
// timeline one for multiple animations
var tl= gsap.timeline({
scrollTrigger: {
trigger: ".page1>h1",
scroller: ".main",
// markers: true,
start: "top 23%",
end: "top 0",
scrub: 3
}
})
// animate h1
tl.to(".page1>h1",{
x: -100
}, "anim")
// animate h2
tl.to(".page1>h2",{
x: 100
}, "anim")
// animate video
tl.to(".page1 video",{
width: "98%"
}, "anim")
// timeline two
var tl2 = gsap.timeline({
scrollTrigger: {
trigger: ".page1>h1",
scroller: ".main",
// markers: true,
start: "top -100%",
end: "top 0",
scrub: 5
}
})
// animate background color
tl2.to(".main", {
backgroundColor: "#fff",
})
// timeline three
var tl2 = gsap.timeline({
scrollTrigger: {
trigger: ".page1>h1",
scroller: ".main",
// markers: true,
start: "top -435%",
end: "top -390%",
scrub: 5
}
})
// animate background color
tl2.to(".main", {
backgroundColor: "#0F0D0D",
})
// animation for nav
var purpleDiv = document.querySelector("#purple");
var purpleDivMarquee = document.querySelector("#purple marquee");
var navItems = document.querySelectorAll("#nav a");
navItems.forEach(function(elems){
var textHere = document.createTextNode(elems.innerText);
elems.addEventListener("mouseenter", function(){
purpleDiv.style.opacity = 1,
purpleDiv.style.display = "block",
purpleDivMarquee.appendChild(textHere)
})
elems.addEventListener("mouseleave", function(){
purpleDiv.style.opacity = 0,
purpleDiv.style.display = "none",
purpleDivMarquee.removeChild(textHere)
})
})