Skip to content

Commit 94694c9

Browse files
authored
Merge pull request #303 from teamEPYC/alevikx-patch-464949
Create scriptSV.js
2 parents 4cc953b + c9a1448 commit 94694c9

File tree

1 file changed

+371
-0
lines changed

1 file changed

+371
-0
lines changed

kaviraj/v2/main/home/scriptSV.js

Lines changed: 371 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,371 @@
1+
import { gridResize, navigation, initializeLenis, visualUtility } from "https://teamepyc.github.io/cdn/kaviraj/v2/utility/global.js";
2+
import { prologueAnimationDesktop, prologueAnimationMobile } from "https://teamepyc.github.io/cdn/kaviraj/v2/main/home/prologue.js";
3+
4+
function mainCode() {
5+
6+
// --- DESKTOP ---//
7+
if (window.innerWidth >= 803) {
8+
9+
//[START] LOAD SEQUENCE [START]//
10+
document.querySelectorAll(".k-hero, .k-hero-heading, .k-hero-subtext, .k-hero-cta").forEach(el => {
11+
el.style.willChange = "transform, opacity, filter";
12+
});
13+
14+
const loaderPrelude = new SplitText(".k-preloader-prelude .k-preloader-prelude-text", { type: "chars" });
15+
16+
const heroHeadings = document.querySelectorAll(".k-hero-heading");
17+
const Lheading1 = new SplitText(heroHeadings[0], { type: "chars" });
18+
const Lheading2 = new SplitText(heroHeadings[1], { type: "chars" });
19+
const Lheading3 = new SplitText(heroHeadings[2], { type: "chars" });
20+
const Lsubtext = new SplitText(".k-hero-subtext", { type: "chars" });
21+
22+
const loadSequence = gsap.timeline({
23+
paused: true
24+
});
25+
26+
loadSequence.fromTo(".k-preloader-content",
27+
{opacity: 1},
28+
{opacity: 0, duration: 0.5, ease: "none", onComplete: () => {document.querySelector(".k-preloader-content")?.remove();}}
29+
).fromTo(".k-preloader-prelude",
30+
{ opacity: 0},
31+
{ opacity: 1, duration: 0}
32+
).fromTo(loaderPrelude.chars,
33+
{ opacity: 0, filter: "blur(10px)" },
34+
{ opacity: 1, filter: "blur(0px)", duration: 1, ease: "power1.out", stagger: 0.1}
35+
).fromTo(".k-preloader-prelude",
36+
{opacity: 1},
37+
{opacity: 0, duration: 1}, "+=0.5"
38+
).fromTo(".k-preloader",
39+
{opacity: 1},
40+
{opacity: 0, duration: 1}, "-=0.5"
41+
).to(".k-background[data-sprite]",
42+
{ease: "none", duration: 2,
43+
onUpdate() {const el = this.targets()[0]; el._spriteSetProgress?.(this.progress());},
44+
onComplete: () => {document.querySelector(".k-preloader")?.remove();}
45+
}, "<"
46+
).fromTo(Lheading1.chars,
47+
{ opacity: 0, scale: 1.5, filter: "blur(10px)" },
48+
{ opacity: 1, scale: 1, filter: "blur(0px)", duration: 1.5, ease: "power3.out", stagger: 0.1}, "-=1.4"
49+
).fromTo(Lheading2.chars,
50+
{ opacity: 0, scale: 1.5, filter: "blur(10px)" },
51+
{ opacity: 1, scale: 1, filter: "blur(0px)", duration: 1.5, ease: "power3.out", stagger: 0.1}, "-=0.7"
52+
).fromTo(Lheading3.chars,
53+
{ opacity: 0, scale: 1.5, filter: "blur(10px)" },
54+
{ opacity: 1, scale: 1, filter: "blur(0px)", duration: 1.5, ease: "power3.out", stagger: 0.1}, "-=0.7"
55+
).fromTo(Lsubtext.chars,
56+
{ opacity: 0 },
57+
{ opacity: 1, duration: 2, ease: "power1.out", stagger: 0.01}, "-=1.4"
58+
).fromTo(".k-hero-content-wrapper .k-solid-button:nth-child(4)",
59+
{y: "0.1rem", opacity: 0},
60+
{y: "0rem", opacity: 1, duration: 0.5}, "-=1.5"
61+
).fromTo(".k-hero-content-wrapper .k-solid-button:nth-child(6)",
62+
{y: "0.1rem", opacity: 0},
63+
{y: "0rem", opacity: 1, duration: 0.5, onComplete: () => {console.log("loadDone")}}, "<+=0.5"
64+
)
65+
66+
document.querySelector(".k-preloader .k-stroke-button")?.addEventListener("click", () => {
67+
gsap.set(window, { scrollTo: 0 });
68+
loadSequence.play();
69+
});
70+
//[END] LOAD SEQUENCE [END]//
71+
72+
73+
74+
//[START] HERO OUTRO [START]//
75+
ScrollTrigger.create({trigger: ".k-hero", start: "0%", end: "100%", pin: true, pinSpacing: false});
76+
77+
const heading1Chars = [...Lheading1.chars].reverse();
78+
const heading2Chars = [...Lheading2.chars].reverse();
79+
const heading3Chars = [...Lheading3.chars].reverse();
80+
const subtextChars = [...Lsubtext.chars].reverse();
81+
82+
const heroOutro = gsap.timeline({
83+
scrollTrigger: {
84+
trigger: ".k-services",
85+
start: "0% 100%",
86+
end: "0% 20%",
87+
scrub: 1,
88+
}
89+
});
90+
91+
heroOutro
92+
.to(".k-hero-content-wrapper .k-solid-button:nth-child(6)", {scale: 0.9, filter: "blur(10px)", opacity: 0, duration: 0.5})
93+
.to(subtextChars, {opacity: 0, stagger: 0.01, duration: 1}, "<")
94+
.to(".k-hero-content-wrapper .k-solid-button:nth-child(4)", {scale: 0.9, filter: "blur(10px)", opacity: 0, duration: 0.5}, "-=1")
95+
.to(heading3Chars, {scale: 0.9, filter: "blur(10px)", scale: 1, opacity: 0, duration: 1, stagger: 0.12}, "-=1")
96+
.to(heading2Chars, {scale: 0.9, filter: "blur(10px)", scale: 1, opacity: 0, duration: 1, stagger: 0.12}, "-=1.35")
97+
.to(heading1Chars, {scale: 0.9, filter: "blur(10px)", scale: 1, opacity: 0, duration: 1, stagger: 0.12}, "-=1.35");
98+
//[END] HERO OUTRO [END]//
99+
100+
101+
102+
//[START] PROLOGUE [START]//
103+
prologueAnimationDesktop();
104+
//[END] PROLOGUE [END]//
105+
106+
107+
108+
//[START] VALUES [START]//
109+
document
110+
.querySelectorAll(
111+
".k-value-intro-text, .k-value-intro-text, .k-cta-headline div, .k-cta-subtext div"
112+
)
113+
.forEach((el) => {
114+
el.style.willChange = "transform, opacity, filter";
115+
});
116+
117+
document.querySelector(".k-background").style.willChange = "transform";
118+
119+
const scrollyVideo = new ScrollyVideo({
120+
scrollyVideoContainer: 'scrolly-video-container',
121+
src: 'https://teamepyc.github.io/cdn/kaviraj/v2/videos/hallway1440p.mp4',
122+
trackScroll: false,
123+
cover: true,
124+
sticky: false,
125+
full: false
126+
});
127+
128+
const valuesTimeline = gsap.timeline({
129+
scrollTrigger: {
130+
trigger: ".k-values",
131+
start: "top bottom",
132+
end: "bottom bottom",
133+
scrub: true
134+
}
135+
});
136+
137+
const kValueIntroText = new SplitText(document.querySelector(".k-value-intro-text"), { type: "chars" });
138+
const kValueOutroText = new SplitText(document.querySelector(".k-value-outro-text"), { type: "chars" });
139+
140+
valuesTimeline
141+
.to(".image-sequence[data-sprite]",
142+
{
143+
ease: "none",
144+
duration: 2,
145+
onUpdate() {
146+
const el = this.targets()[0];
147+
el._spriteSetProgress?.(this.progress());
148+
}
149+
}
150+
)
151+
.fromTo(
152+
kValueIntroText.chars,
153+
{ filter: "blur(10px)", scale: 1.5, opacity: 0 },
154+
{ filter: "blur(0px)", scale: 1, opacity: 1, stagger: 0.02, duration: 0.5, ease: "power1.out" },
155+
"<+=0.5"
156+
)
157+
.to(
158+
[kValueIntroText.chars],
159+
{ filter: "blur(10px)", scale: 1, opacity: 0, duration: 0.5, stagger: 0.02 }
160+
)
161+
.fromTo(
162+
".image-sequence",
163+
{ filter: "contrast(80%)" },
164+
{ filter: "contrast(100%)", duration: 0.5 },
165+
"<"
166+
)
167+
.fromTo(
168+
kValueOutroText.chars,
169+
{ filter: "blur(10px)", scale: 1.5, opacity: 0 },
170+
{ filter: "blur(0px)", scale: 1, opacity: 1, stagger: 0.01, duration: 0.5, ease: "power1.out" },
171+
"8.9"
172+
)
173+
.fromTo(
174+
".image-sequence",
175+
{ filter: "contrast(100%)" },
176+
{ filter: "contrast(80%)", duration: 0.5 },
177+
"<-=1"
178+
)
179+
.to(
180+
[kValueOutroText.chars],
181+
{ filter: "blur(10px)", scale: 1, opacity: 0, duration: 0.4, stagger: 0.01 },
182+
"+=0.2"
183+
)
184+
.fromTo(
185+
".image-sequence",
186+
{ filter: "contrast(80%)" },
187+
{ filter: "contrast(100%)", duration: 0.5 },
188+
"<"
189+
)
190+
.to({},
191+
{ duration: 10.35, ease: "none",
192+
onUpdate(){ {
193+
const f = this.progress();
194+
scrollyVideo.setTargetTimePercent(f);
195+
}},
196+
},
197+
"2"
198+
)
199+
.to(
200+
".k-background",
201+
{ duration: 2.23, scale: 1.2, y: "-10%", ease: "none" },
202+
"-=2.23"
203+
)
204+
.to(".lake", { opacity: 1, duration: 0.1 })
205+
.fromTo(
206+
".k-cta-content-block",
207+
{ opacity: 0 },
208+
{ opacity: 1, duration: 0.5 },
209+
"-=0.5"
210+
);
211+
212+
if (window.ScrollTrigger) ScrollTrigger.refresh();
213+
214+
215+
//[END] VALUES [END]//
216+
217+
218+
219+
//[START] CTA [START]//
220+
const kCtaHeadline = new SplitText(document.querySelector(".k-cta-headline"), { type: "chars" });
221+
const kCtaSubtext = new SplitText(document.querySelector(".k-cta-subtext"), { type: "chars" });
222+
const kCTA = gsap.timeline({
223+
scrollTrigger: {
224+
trigger: ".k-values",
225+
start: "95% 80%",
226+
end: "100% 90%",
227+
scrub: true
228+
}
229+
});
230+
231+
kCTA.fromTo(".k-cta",
232+
{pointerEvents: "none"},
233+
{pointerEvents: "auto"}
234+
).fromTo(".k-logo-icon.cta",
235+
{opacity: 0},
236+
{opacity: 1, duration: 2}
237+
).fromTo(kCtaHeadline.chars,
238+
{filter: "blur(4px)", opacity: 0},
239+
{filter: "blur(0px)", opacity: 1, stagger: 0.1, duration: 2, ease: "power1.out"}, "<+=1"
240+
).fromTo(kCtaSubtext.chars,
241+
{filter: "blur(1px)", opacity: 0},
242+
{filter: "blur(0px)", opacity: 1, stagger: 0.01, duration: 2, ease: "power1.out"}, "<+=3"
243+
).fromTo(".k-cta .k-solid-button",
244+
{filter: "blur(2px)", scale: 0.9, opacity: 0},
245+
{filter: "blur(0px)", scale: 1, opacity: 1, duration: 2}, "<+=1"
246+
);
247+
//[END] CTA [END]//
248+
249+
250+
//[START] AUDIO [START]//
251+
const audio = new Audio('https://teamepyc.github.io/cdn/kaviraj/v2/sound.mp3');
252+
audio.preload = 'auto';
253+
audio.loop = true;
254+
let isPlaying = false;
255+
256+
function toggleSound() {
257+
if (isPlaying) {
258+
audio.pause();
259+
isPlaying = false;
260+
soundToggleButton.classList.add('paused');
261+
} else {
262+
audio.play();
263+
isPlaying = true;
264+
soundToggleButton.classList.remove('paused');
265+
}
266+
}
267+
const soundToggleButton = document.querySelector('.k-nav-sound');
268+
soundToggleButton.addEventListener('click', () => {
269+
toggleSound();
270+
});
271+
272+
const loaderButton = document.querySelector('.k-stroke-button.loader');
273+
loaderButton.addEventListener('click', () => {
274+
toggleSound();
275+
});
276+
//[END] AUDIO [END]//
277+
278+
}
279+
// --- [END] DESKTOP [END] ---//
280+
281+
282+
// --- MOBILE ---//
283+
if (window.innerWidth < 803) {
284+
prologueAnimationMobile();
285+
286+
document.querySelectorAll('.k-value-frame').forEach(el => {
287+
el.removeAttribute('data-cutout-inset');
288+
el.removeAttribute('data-inset-width');
289+
el.removeAttribute('data-inset-padding');
290+
});
291+
292+
const scrollyVideo = new ScrollyVideo({
293+
scrollyVideoContainer: "scrolly-video",
294+
src: "https://teamepyc.github.io/cdn/kaviraj/v2/videos/hallway_mobile.mp4",
295+
trackScroll: false,
296+
sticky: false,
297+
useWebCodecs: false,
298+
});
299+
300+
const mobileImageSequence = gsap.timeline({
301+
scrollTrigger: {
302+
trigger: ".k-values",
303+
start: "top bottom",
304+
end: "bottom bottom",
305+
scrub: true
306+
}
307+
});
308+
309+
const kValueIntroText = new SplitText(document.querySelector(".k-value-intro-text"), { type: "chars" });
310+
const kValueOutroText = new SplitText(document.querySelector(".k-value-outro-text"), { type: "chars" });
311+
312+
mobileImageSequence
313+
.to(".k-background[data-sprite]",
314+
{ease: "none", duration: 4, onUpdate() {const el = this.targets()[0]; el._spriteSetProgress?.(this.progress());}})
315+
.fromTo(kValueIntroText.chars,
316+
{opacity: 0},
317+
{opacity: 1, stagger: 0.02, duration: 0.5, ease: "power1.out"}, "<+=2.3")
318+
.to([kValueIntroText.chars],
319+
{opacity: 0, duration: 0.5, stagger: 0.02}, "+=1")
320+
.fromTo(".k-background",
321+
{y: 0},
322+
{y: 0, duration: 0.5}, "<")
323+
.fromTo(kValueOutroText.chars,
324+
{opacity: 0},
325+
{opacity: 1, stagger: 0.01, duration: 0.5, ease: "power1.out"}, "+=14")
326+
.fromTo(".k-background",
327+
{y: 0},
328+
{y: 0, duration: 0.5}, "<-=1")
329+
.to([kValueOutroText.chars],
330+
{scale: 1, opacity: 0, duration: 0.4, stagger: 0.01}, "+=1")
331+
.fromTo(".k-background",
332+
{y:0 },
333+
{y: 0, duration: 0.5}, "<")
334+
.to({}, {
335+
duration: 5,
336+
onUpdate(){ {
337+
const f = this.progress();
338+
scrollyVideo.setVideoPercentage(f, {transitionSpeed: 12});
339+
}},
340+
})
341+
.fromTo(".k-cta-content-block",
342+
{opacity: 0}, {opacity: 1, duration: 0.5}, "-=0.5");
343+
344+
}
345+
346+
}
347+
348+
349+
window.addEventListener('load', async () => {
350+
gridResize();
351+
352+
if (window.innerWidth > 803) {
353+
initializeLenis();
354+
}
355+
356+
if (window.innerWidth < 803) {
357+
//document.querySelector('.k-background').removeAttribute('data-sprite');
358+
document.querySelector('.k-menu').removeAttribute('data-sprite');
359+
document.querySelector('.image-sequence').removeAttribute('data-sprite');
360+
document.querySelector('.k-background').setAttribute('data-sprite-url', 'https://cdn.prod.website-files.com/6904a418739bb0c76ab91cce/6915dd814981776bd91c2471_spritesheet_mobile.png');
361+
}
362+
363+
visualUtility();
364+
365+
if (window.spriteMasksReady) {
366+
await window.spriteMasksReady;
367+
}
368+
369+
mainCode();
370+
navigation();
371+
});

0 commit comments

Comments
 (0)