-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
225 lines (195 loc) · 5.51 KB
/
Copy pathscript.js
File metadata and controls
225 lines (195 loc) · 5.51 KB
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
// Initialize Lenis for smooth scrolling
const lenis = new Lenis({
duration: 1.2,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
smooth: true,
});
function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
// Initialize GSAP
gsap.registerPlugin(ScrollTrigger);
// Custom Cursor
const cursor = document.querySelector('.cursor-follower');
let mouseX = 0;
let mouseY = 0;
let cursorX = 0;
let cursorY = 0;
document.addEventListener('mousemove', (e) => {
mouseX = e.clientX;
mouseY = e.clientY;
});
// Smooth cursor animation loop
function animateCursor() {
let distX = mouseX - cursorX;
let distY = mouseY - cursorY;
cursorX += distX * 0.1; // Ease factor
cursorY += distY * 0.1;
cursor.style.left = cursorX + 'px';
cursor.style.top = cursorY + 'px';
requestAnimationFrame(animateCursor);
}
animateCursor();
// Hover interactions for cursor
const links = document.querySelectorAll('a, button, .project-item');
links.forEach(link => {
link.addEventListener('mouseenter', () => {
cursor.style.transform = 'translate(-50%, -50%) scale(2.5)';
cursor.style.backgroundColor = 'transparent';
cursor.style.border = '1px solid currentColor';
cursor.style.mixBlendMode = 'normal';
});
link.addEventListener('mouseleave', () => {
cursor.style.transform = 'translate(-50%, -50%) scale(1)';
cursor.style.backgroundColor = 'var(--text-color)';
cursor.style.border = 'none';
cursor.style.mixBlendMode = 'difference';
});
});
// Hero Animation
const heroTimeline = gsap.timeline();
heroTimeline.from('.hero-title .line', {
y: 100,
opacity: 0,
duration: 1.5,
stagger: 0.2,
ease: 'power4.out',
delay: 0.5
})
.to('.hero-subtitle', {
opacity: 1,
duration: 1,
y: 0,
ease: 'power2.out'
}, '-=0.5');
// Parallax Effect for Hero Image
gsap.to('.hero-image', {
scrollTrigger: {
trigger: '.hero',
start: 'top top',
end: 'bottom top',
scrub: true
},
y: 100,
scale: 1.1
});
// Work Section Animations
const projects = document.querySelectorAll('.project-item');
projects.forEach((project, index) => {
// Fade up text
gsap.from(project.querySelector('.project-info'), {
scrollTrigger: {
trigger: project,
start: 'top 80%',
toggleActions: 'play none none reverse'
},
y: 50,
opacity: 0,
duration: 1,
ease: 'power3.out'
});
// Reveal image
gsap.from(project.querySelector('.project-image-wrapper'), {
scrollTrigger: {
trigger: project,
start: 'top 80%',
toggleActions: 'play none none reverse'
},
y: 100,
opacity: 0,
duration: 1.2,
delay: 0.2,
ease: 'power3.out'
});
});
// Studio Text Reveal
gsap.from('.studio-title', {
scrollTrigger: {
trigger: '.studio',
start: 'top 70%',
},
y: 50,
opacity: 0,
duration: 1,
ease: 'power3.out'
});
gsap.from('.studio-text', {
scrollTrigger: {
trigger: '.studio',
start: 'top 70%',
},
y: 50,
opacity: 0,
duration: 1,
delay: 0.3,
ease: 'power3.out'
});
// Marquee Animation
gsap.to('.marquee-inner', {
xPercent: -50,
ease: 'none',
duration: 15,
repeat: -1
});
// Services Stagger
gsap.from('.service-item', {
scrollTrigger: {
trigger: '.services',
start: 'top 70%'
},
y: 50,
opacity: 0,
duration: 0.8,
stagger: 0.1,
ease: 'power2.out'
});
// Magnetic Buttons (Simple implementation)
const magneticBtns = document.querySelectorAll('.btn-arrow, .nav-link, .menu-btn');
magneticBtns.forEach(btn => {
btn.addEventListener('mousemove', (e) => {
const rect = btn.getBoundingClientRect();
const x = e.clientX - rect.left - rect.width / 2;
const y = e.clientY - rect.top - rect.height / 2;
gsap.to(btn, {
x: x * 0.3,
y: y * 0.3,
duration: 0.3
});
});
btn.addEventListener('mouseleave', () => {
gsap.to(btn, {
x: 0,
y: 0,
duration: 0.3
});
});
});
// Card Stack Animation
// Cards are now positioned absolute in a sticky wrapper.
// We animate them to rotate and spread out as the user scrolls through the 300vh section.
const cardSection = document.querySelector('.card-stack-section');
const cards = document.querySelectorAll('.card');
if (cardSection && cards.length > 0) {
// Animate each card
cards.forEach((card, index) => {
// Calculate spread
// Index 0: left, Index 3: right
const rotation = (index - 1.5) * 12; // -18deg to +18deg
const xOffset = (index - 1.5) * 60; // Spread horizontally
const yOffset = (index - 1.5) * 10; // Classic fanning curve (middle higher) comes from abs()
gsap.to(card, {
scrollTrigger: {
trigger: '.card-stack-section',
start: 'top top',
end: 'bottom bottom',
scrub: 1
},
rotation: rotation,
x: xOffset,
y: Math.abs(index - 1.5) * 15, // Slight arc
ease: 'none'
});
});
}