-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
343 lines (275 loc) · 9.64 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
locoScroll = () => {
gsap.registerPlugin(ScrollTrigger);
// Using Locomotive Scroll from Locomotive https://github.com/locomotivemtl/locomotive-scroll
const locoScroll = new LocomotiveScroll({
el: document.querySelector("#main"),
smooth: true
});
// each time Locomotive Scroll updates, tell ScrollTrigger to update too (sync positioning)
locoScroll.on("scroll", ScrollTrigger.update);
// tell ScrollTrigger to use these proxy methods for the "#main" element since Locomotive Scroll is hijacking things
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 };
},
// LocomotiveScroll handles things completely differently on mobile devices - it doesn't even transform the container at all! So to get the correct behavior and avoid jitters, we should pin things with position: fixed on mobile. We sense it by checking to see if there's a transform applied to the container (the LocomotiveScroll-controlled element).
pinType: document.querySelector("#main").style.transform ? "transform" : "fixed"
});
// each time the window updates, we should refresh ScrollTrigger and then update LocomotiveScroll.
ScrollTrigger.addEventListener("refresh", () => locoScroll.update());
// after everything is set up, refresh() ScrollTrigger and update LocomotiveScroll because padding may have been added for pinning, etc.
ScrollTrigger.refresh();
}
locoScroll();
// -----------------------------------
dot = () => {
var main = document.querySelector('#main');
// var vid = document.querySelector('.page1 video')
var dot = document.querySelector('#cursor');
document.addEventListener('mousemove', function (dets) {
// using gsap for smooth flow
gsap.to(dot, {
x: dets.x, // Adding 10 to dets.x
y: dets.y,
opacity: 1,
})
})
main.addEventListener('mouseleave', function () {
gsap.to(dot, {
scale: 1,
opacity: 0,
})
})
}
dot();
// ---------------------------------------------------------
cursor = () => {
const button = document.querySelector('button');
let boundingRect = button.getBoundingClientRect();
window.addEventListener('resize', () => {
boundingRect = button.getBoundingClientRect();
});
button.addEventListener('mousemove', (e) => {
const mousePosX = e.pageX - boundingRect.left;
const mousePosY = e.pageY - boundingRect.top;
gsap.to(button, {
x: (mousePosX - boundingRect.width / 2) * 0.4,
y: (mousePosY - boundingRect.height / 2) * 0.4,
duration: 0.8,
});
console.log("a")
});
button.addEventListener('mouseleave', () => {
gsap.to(button, {
x: 0,
y: 0,
duration: 0.8,
ease: 'elastic.out(1,0.3)'
});
});
}
cursor();
// ----------------------------------------------------------
gsap.from(".page1 h1,.page1 h2", {
y: 30,
rotate: 10,
opacity: 0,
delay: 0.3,
duration: 1
})
an = () => {
var isMobile = window.innerWidth <= 768; // Change this value based on your mobile breakpoint
var tl = gsap.timeline({
scrollTrigger: {
// trigger: '.page1 h1',
trigger: '.page1 h1',
scroller: '#main',
// markers: true,
scrub: 3,
start: 'top 10%',
end: 'top 0',
}
})
if (isMobile) {
// Mobile animations
tl.to('.page1 h1', {
x: 0, // Change these values as needed
duration: 1,
}, 'anim')
tl.to('.page1 h2', {
x: 0, // Change these values as needed
duration: 1,
}, 'anim')
tl.to('.page1 video', {
height: '100vh',
delay: .1,
},)
} else {
// Desktop animations
tl.to('.page1 h1', {
x: -100,
duration: 1,
}, 'anim')
tl.to('.page1 h2', {
x: 100,
duration: 1,
}, 'anim')
tl.to('.page1 video', {
width: '90%',
delay: .1,
},)
}
var tl2 = gsap.timeline({
scrollTrigger: {
trigger: '.page1 h1',
scroller: '#main',
// markers: true,
scrub: 3,
start: isMobile ? 'top -50%' : 'top -120%', // Adjust these values as needed
end: isMobile ? 'top -60%' : 'top -130%', // Adjust these values as needed
}
})
tl2.to('#main', {
backgroundColor: '#fff',
})
var tl3 = gsap.timeline({
scrollTrigger: {
trigger: '.page1 h1',
scroller: '#main',
// markers: true,
scrub: 3,
start: isMobile ? 'top -140%' : 'top -280%', // Adjust these values as needed
end: isMobile ? 'top -150%' : 'top -300%', // Adjust these values as needed
}
})
tl3.to('#main', {
backgroundColor: '#0f0d0d',
color: 'white',
})
}
an();
// -------------------------------------------------------
vid = () => {
// var p1 = document.querySelector('page1')
var vid = document.querySelector('.page1 video')
var dot = document.querySelector('#cursor');
// const transVal = dot.style.transition;
vid.addEventListener('mouseenter', function () {
dot.innerHTML = "sound on";
dot.style.width = '7%';
dot.style.display = 'flex';
dot.style.alignItems = 'center';
dot.style.justifyContent = 'center';
dot.style.fontSize = '12px';
dot.style.padding = ' 0px 15px';
dot.style.borderRadius = '50px';
dot.style.color = '#000';
// dot.style.transition = '0.3s ease-in'
});
vid.addEventListener('click', function () {
if (vid.muted) {
vid.muted = false;
dot.innerHTML = "sound off";
} else {
vid.muted = true;
dot.innerHTML = "";
}
});
vid.addEventListener('mouseleave', function () {
dot.innerHTML = ""; // Clear the content of the dot element
dot.style.width = '0'; // Reset the width of the dot element
dot.style.width = '30px';
dot.style.display = 'block';
dot.style.fontSize = '0';
dot.style.padding = ' 0';
dot.style.borderRadius = '50px';
// dot.style.transition = 'background-image ease 0.5s'
gsap.to(dot, {
opacity: 1,
})
});
}
vid();
// -----------------------------------------------------
loop = ()=>{
// Select all the h4 tags in the nav tag
let navH4s = document.querySelectorAll('nav h4');
// Loop through each h4 tag
navH4s.forEach(function(navH4) {
// Add mouseover event listener
navH4.addEventListener('mouseover', function() {
// Get the h4 content
let h4Content = this.innerHTML;
// Select all the h1 tags in the div with the elem class and nav id
let elemH1s = document.querySelectorAll('#nav .marquee h1');
// Loop through each h1 tag
elemH1s.forEach(function(elemH1) {
// Set the h1 content
elemH1.innerHTML = h4Content;
elemH1.style.fontSize = '10vw';
elemH1.style.fontWeight = '100';
elemH1.style.zIndex = '7';
});
});
});
var nav = document.querySelector('#nav')
var navi = document.querySelector('nav')
var h4 = document.querySelectorAll('nav h4')
h4.forEach(function (elem) {
elem.addEventListener('mousemove', function () {
nav.style.display = 'flex';
nav.style.opacity = '1';
})
navi.addEventListener('mouseleave', function () {
nav.style.display = 'none';
nav.style.opacity = '0';
})
});
}
loop();
// ------------------------------------------
box = ()=>{
// var p4 = document.querySelector('.page4')
document.querySelectorAll('.box').forEach(function(elem){
elem.addEventListener("mousemove", function (dets) {
gsap.to(elem.querySelector("img"), {
opacity: 1,
ease: Power3,
x: dets.x ,
y: dets.y ,
});
});
elem.addEventListener("mouseleave", function() {
gsap.to(elem.querySelector("img"), {
opacity: 0,
ease: Power3,
duration: 0.5,
});
});
});
}
box();
// ---------------------
// ------------------------------------
// var dot = document.querySelector('#cursor')
// var boxes = document.querySelectorAll('.box');
// boxes.forEach(function (elem) {
// elem.addEventListener('mouseenter', function (dets) {
// var att = elem.getAttribute('data-image')
// dot.style.width = '30vw';
// dot.style.height = '45vh';
// dot.style.mixBlendMode = 'normal';
// dot.style.borderRadius = '0';
// dot.style.backgroundImage = `url(${att})`;
// })
// elem.addEventListener('mouseleave', function (dets) {
// dot.style.width = '30px';
// dot.style.height = '30px';
// dot.style.borderRadius = '50%';
// dot.style.backgroundImage = 'none';
// dot.style.mixBlendMode = 'difference';
// })
// })