379 lines
22 KiB
JavaScript
379 lines
22 KiB
JavaScript
(()=>{
|
|
const stage=document.querySelector("[data-stage]");
|
|
const root=document.documentElement;
|
|
if(!stage||!window.gsap||!window.ScrollTrigger){root.classList.add("is-ready");return}
|
|
gsap.registerPlugin(ScrollTrigger);
|
|
setTimeout(()=>{if(!root.classList.contains("is-ready")){stage.classList.add("stage--ready");root.classList.add("is-ready");stage.classList.remove("stage--boot")}},10000);
|
|
|
|
const hero=stage.querySelector("[data-stage-hero]"),trust=stage.querySelector("[data-stage-trust]");
|
|
const word=stage.querySelector("[data-stage-word]"),fades=[...stage.querySelectorAll("[data-stage-fade]")];
|
|
const sand=stage.querySelector("[data-stage-sand]"),howto=stage.querySelector("[data-stage-howto]"),learn=stage.querySelector("[data-stage-learn]"),sea=stage.querySelector("[data-stage-sea]"),prog=stage.querySelector("[data-stage-prog]"),iris=stage.querySelector("[data-stage-iris]"),ring=stage.querySelector("[data-stage-ring]"),team=stage.querySelector("[data-stage-team]"),rev=stage.querySelector("[data-stage-rev]"),price=stage.querySelector("[data-stage-price]"),sky=stage.querySelector("[data-stage-sky]");
|
|
const reduce=matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
const fast=stage.classList.contains("stage--fast");
|
|
const blur=v=>reduce||fast?"none":`blur(${v}px)`;
|
|
const hold=fast?0:1;
|
|
const touch=matchMedia("(pointer: coarse)").matches;
|
|
|
|
const rng=seed=>()=>{seed=(seed*1664525+1013904223)>>>0;return seed/4294967296};
|
|
const sandRidge=(y,i,w)=>{
|
|
const silhouettes=[
|
|
'M-350 35C-120 42 90 72 230 4C352 -56 359 -126 507 -139C680 -154 827 -71 979 -62C1122 -53 1114 -212 1242 -227C1367 -244 1464 -150 1582 -175C1735 -207 1765 -320 1930 -311C2091 -302 2229 -220 2398 -248C2531 -270 2650 -343 2950 -318L2950 -154C2670 -176 2544 -102 2385 -89C2180 -70 2075 -142 1914 -146C1737 -150 1692 -39 1558 -26C1400 -11 1339 -94 1228 -63C1119 -33 1159 94 992 104C819 114 670 28 510 51C360 72 340 150 212 179C43 216 -133 175 -350 190Z',
|
|
'M-350 40C-131 14 63 112 238 43C380 -14 409 -91 539 -102C674 -114 772 -18 899 -47C1000 -70 1002 -186 1113 -206C1241 -229 1365 -151 1499 -164C1652 -179 1681 -285 1829 -304C1998 -325 2121 -220 2292 -255C2445 -285 2571 -366 2950 -325L2950 -165C2601 -202 2485 -113 2308 -97C2134 -82 1981 -168 1833 -122C1692 -77 1673 7 1511 16C1341 24 1233 -56 1139 -9C1063 29 1070 121 927 137C780 155 675 60 534 83C407 104 364 183 223 211C39 248 -138 178 -350 205Z'
|
|
];
|
|
const crest=[
|
|
'M-350 35C-120 42 90 72 230 4C352 -56 359 -126 507 -139C680 -154 827 -71 979 -62C1122 -53 1114 -212 1242 -227C1367 -244 1464 -150 1582 -175C1735 -207 1765 -320 1930 -311C2091 -302 2229 -220 2398 -248C2531 -270 2650 -343 2950 -318L2950 -296C2650 -321 2537 -245 2401 -225C2220 -198 2089 -279 1927 -286C1776 -293 1738 -183 1588 -150C1462 -123 1360 -219 1244 -202C1125 -184 1137 -25 982 -35C819 -27 675 -127 510 -112C372 -99 361 -27 241 31C93 101 -121 70 -350 61Z',
|
|
'M-350 40C-131 14 63 112 238 43C380 -14 409 -91 539 -102C674 -114 772 -18 899 -47C1000 -70 1002 -186 1113 -206C1241 -229 1365 -151 1499 -164C1652 -179 1681 -285 1829 -304C1998 -325 2121 -220 2292 -255C2445 -285 2571 -366 2950 -325L2950 -304C2574 -342 2455 -260 2295 -231C2110 -196 1997 -301 1833 -276C1696 -257 1655 -152 1501 -139C1358 -124 1241 -200 1118 -180C1014 -163 1016 -41 904 -20C764 7 673 -88 541 -75C421 -63 393 10 246 69C63 140 -132 40 -350 65Z'
|
|
];
|
|
return `<g transform="translate(0 ${y}) scale(${w/2600} 1)"><path d="${silhouettes[i%2]}" fill="#F7E4BD" opacity=".82"/><path d="${crest[i%2]}" fill="#F0D6A3" opacity=".66"/></g>`;
|
|
};
|
|
const sandGrains=(count,w,h,start,r)=>{let s='';for(let i=0;i<count;i++){const x=r()*w,y=start+r()*(h-start),rx=1.8+r()*3.9,ry=rx*(.65+r()*.6),angle=r()*180;s+=`<ellipse cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" rx="${rx.toFixed(1)}" ry="${ry.toFixed(1)}" transform="rotate(${angle.toFixed(0)} ${x.toFixed(1)} ${y.toFixed(1)})" fill="${i%3?'#E4C582':'#EED5A5'}" opacity="${(.45+r()*.3).toFixed(2)}"/>`;}return s;};
|
|
(()=>{
|
|
const W=2600,H=5200,r=rng(5);
|
|
const step=o=>`M-300 ${120+o}C400 ${60+o} 800 ${110+o} 1150 ${330+o}S1800 ${640+o} 2900 ${600+o}L2900 ${H}L-300 ${H}Z`;
|
|
let stripes='';
|
|
for(let y=980,i=0;y<H+450;y+=490,i++)stripes+=sandRidge(y,i,W);
|
|
const grains=sandGrains(800,W,H,700,r);
|
|
sand.innerHTML=`<svg class="stage__sand-svg" viewBox="0 0 ${W} ${H}"><g transform="rotate(3 ${W/2} ${H/2})"><path d="${step(-120)}" fill="#F8B994"/><path d="${step(0)}" fill="#FCEACA"/>${stripes}${grains}</g></svg>`;
|
|
})();
|
|
|
|
if(sky){
|
|
const W=2600,H=5200;
|
|
const step=o=>`M-300 ${120+o}C400 ${60+o} 800 ${110+o} 1150 ${330+o}S1800 ${640+o} 2900 ${600+o}L2900 ${H}L-300 ${H}Z`;
|
|
sky.innerHTML=`<svg class="stage__sand-svg" viewBox="0 0 ${W} ${H}"><g transform="translate(${W} 0) scale(-1 1) rotate(3 ${W/2} ${H/2})"><path d="${step(-120)}" fill="#C4E5E3"/><path d="${step(0)}" fill="#97CFCD"/></g></svg>`;
|
|
}
|
|
const seaEdge=(y,amp,seg,w,ph)=>{let d=`M-100 ${y}`;for(let x=-100;x<=w+100;x+=seg){const k=Math.sin((x/seg)*1.9+ph)*amp+Math.sin((x/seg)*.7+ph*2)*amp*.6;d+=`Q${x+seg/2} ${y+k*1.3} ${x+seg} ${y+k*.4}`}return d};
|
|
sea.innerHTML=`<svg class="stage__sea-svg"><defs><filter id="stage-foam" x="-5%" y="-20%" width="110%" height="140%"><feTurbulence type="fractalNoise" baseFrequency=".006 .012" numOctaves="2" seed="11"/><feDisplacementMap in="SourceGraphic" scale="90"/></filter></defs><path data-wet fill="#F3D9AE" opacity=".55"/><g data-foam filter="url(#stage-foam)"><path fill="#fff"/></g><clipPath id="stage-water-clip"><path data-water-clip/></clipPath><path data-water fill="#94CECD"/><g clip-path="url(#stage-water-clip)"><svg data-sea-copy x="0" width="100%" height="100%"></svg></g></svg>`;
|
|
const seaWet=sea.querySelector("[data-wet]"),seaFoam=sea.querySelector("[data-foam]"),seaWater=sea.querySelector("[data-water]"),seaClip=sea.querySelector("[data-water-clip]"),seaCopy=sea.querySelector("[data-sea-copy]");
|
|
const progSea=stage.querySelector("[data-stage-prog] .prog__sea");
|
|
if(progSea){seaCopy.setAttribute("viewBox",progSea.getAttribute("viewBox"));seaCopy.setAttribute("preserveAspectRatio",progSea.getAttribute("preserveAspectRatio"));seaCopy.innerHTML=progSea.innerHTML}
|
|
const seaState={f:0};
|
|
let seaKey="";
|
|
const drawSea=()=>{
|
|
const f=seaState.f,W=innerWidth,H=innerHeight,key=`${f}|${W}|${H}`;
|
|
if(W<50||H<50)return;
|
|
if(key===seaKey)return;
|
|
seaKey=key;
|
|
const top=H*(1.45-1.68*f),foamTop=top-H*.2*(1-f*.5),end=`L${W+100} ${H+200}L-100 ${H+200}Z`;
|
|
seaWet.setAttribute("d",seaEdge(foamTop-H*.06,H*.05,W/3.5,W,f*1.4+.5)+end);
|
|
seaFoam.firstChild.setAttribute("d",seaEdge(foamTop,H*.07,W/4,W,f*3)+end);
|
|
seaFoam.style.opacity=f<.85?1:Math.max(0,1-(f-.85)/.15);
|
|
const wd=seaEdge(top,H*.045,W/4.3,W,f*2.2+1)+end;seaWater.setAttribute("d",wd);seaClip.setAttribute("d",wd);
|
|
seaCopy.setAttribute("y",(top-H*(1.45-1.68)).toFixed(1));
|
|
};
|
|
drawSea();
|
|
addEventListener("resize",drawSea);
|
|
|
|
let lenis=null;
|
|
if(!reduce&&!touch&&window.Lenis){
|
|
lenis=new Lenis();
|
|
lenis.on("scroll",ScrollTrigger.update);
|
|
gsap.ticker.add(t=>lenis.raf(t*1000));
|
|
gsap.ticker.lagSmoothing(0);
|
|
}
|
|
|
|
const nav=performance.getEntriesByType("navigation")[0];
|
|
let quick=scrollY>0||(!!nav&&nav.type!=="navigate");
|
|
let now=0;
|
|
let rush=false,rushTimer=0;
|
|
const finishAll=()=>stage.getAnimations({subtree:true}).forEach(a=>{
|
|
const timing=a.effect&&a.effect.getComputedTiming();
|
|
if(timing&&timing.iterations!==Infinity&&a.playState!=="finished")a.finish();
|
|
});
|
|
const setRush=(on,ms=0)=>{
|
|
clearTimeout(rushTimer);
|
|
rush=on;
|
|
if(!on)return;
|
|
finishAll();
|
|
requestAnimationFrame(()=>requestAnimationFrame(finishAll));
|
|
if(ms)rushTimer=setTimeout(()=>{finishAll();rush=false},ms);
|
|
};
|
|
if(quick)stage.classList.add("stage--boot");
|
|
hero.classList.add("soft--play");
|
|
const lockKeys=[" ","ArrowDown","ArrowUp","PageDown","PageUp","End","Home"];
|
|
const swallow=event=>{
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
};
|
|
const swallowKey=event=>{if(lockKeys.includes(event.key))swallow(event)};
|
|
const introEvents=["wheel","touchstart","keydown","pointerdown"];
|
|
const speedUpIntro=event=>{
|
|
introEvents.forEach(type=>removeEventListener(type,speedUpIntro,true));
|
|
const running=hero.getAnimations({subtree:true}).filter(a=>a.playState!=="finished");
|
|
if(!running.length)return;
|
|
if(quick||now>tl.labels.fly){running.forEach(a=>a.finish());return}
|
|
running.forEach(a=>{a.playbackRate=6});
|
|
if(event.type==="wheel")swallow(event);else if(event.type==="keydown")swallowKey(event);
|
|
addEventListener("wheel",swallow,{capture:true,passive:false});
|
|
addEventListener("touchmove",swallow,{capture:true,passive:false});
|
|
addEventListener("keydown",swallowKey,true);
|
|
let locked=true;
|
|
const unlock=()=>{
|
|
if(!locked)return;
|
|
locked=false;
|
|
removeEventListener("wheel",swallow,true);
|
|
removeEventListener("touchmove",swallow,true);
|
|
removeEventListener("keydown",swallowKey,true);
|
|
};
|
|
Promise.allSettled(running.map(a=>a.finished)).then(unlock);
|
|
setTimeout(unlock,1200);
|
|
};
|
|
introEvents.forEach(type=>addEventListener(type,speedUpIntro,{capture:true,passive:type!=="wheel"}));
|
|
let teamTl=null;
|
|
const teamEnter=()=>{
|
|
if(team.classList.contains("team--play"))return;
|
|
team.classList.add("team--play");
|
|
iris.classList.add("stage__iris--closed");
|
|
const items=[...team.querySelectorAll(".team__item")];
|
|
if(reduce||quick||rush){gsap.set(items,{autoAlpha:1});return}
|
|
const photos=items.map(i=>i.querySelector(".team__photo")),rest=items.map(i=>[...i.children].filter(c=>!c.classList.contains("team__photo")));
|
|
gsap.set(items,{autoAlpha:1,backgroundColor:"rgba(255,255,255,0)",borderColor:"rgba(255,255,255,0)"});
|
|
gsap.set(rest.flat(),{autoAlpha:0,y:-12});
|
|
gsap.set(photos,{clipPath:"circle(0% at 50% 50%)"});
|
|
const box=stage.querySelector(".stage__sticky").getBoundingClientRect(),cx=box.width/2,cy=box.height/2;
|
|
const tl2=gsap.timeline({onComplete:()=>{teamTl=null}});
|
|
teamTl=tl2;
|
|
photos.forEach((ph,k)=>{
|
|
const r=ph.getBoundingClientRect(),dot=document.createElement("i");
|
|
dot.className="stage__dot";dot.setAttribute("aria-hidden","true");
|
|
stage.querySelector(".stage__sticky").append(dot);
|
|
const d0=.04*Math.max(innerWidth,innerHeight);gsap.set(dot,{x:cx,y:cy,xPercent:-50,yPercent:-50,width:d0,height:d0});
|
|
tl2.to(dot,{x:r.left-box.left+r.width/2,y:r.top-box.top+r.height/2,width:24,height:24,duration:.5,ease:"power2.inOut"},k*.06)
|
|
.to(dot,{width:r.width,height:r.height,autoAlpha:0,duration:.4,ease:"power2.out",onComplete:()=>dot.remove()},.5+k*.06)
|
|
.to(ph,{clipPath:"circle(50% at 50% 50%)",duration:.45,ease:"power2.out"},.52+k*.06)
|
|
.to(items[k],{backgroundColor:"rgba(255,255,255,.16)",borderColor:"rgba(255,255,255,.45)",duration:.4},.9+k*.1)
|
|
.to(rest[k],{autoAlpha:1,y:0,duration:.4,stagger:.06,ease:"power2.out"},1+k*.1);
|
|
});
|
|
};
|
|
const trustIn=trust.querySelector(".trust__inner");
|
|
gsap.set([trustIn,howto,learn,prog,team,rev,price].filter(Boolean),{autoAlpha:0});
|
|
|
|
let sync=()=>{};
|
|
const ez=e=>reduce?"steps(1)":e;
|
|
const tl=gsap.timeline({
|
|
defaults:{ease:"none"},
|
|
scrollTrigger:{
|
|
trigger:stage,start:"top top",end:"bottom bottom",scrub:fast?.5:true,invalidateOnRefresh:true,
|
|
onUpdate:self=>{if(Math.abs(self.getVelocity())>8000)setRush(true,350);else if(rush)finishAll();sync(self.progress*self.animation.duration())},
|
|
onRefresh:self=>{drawSea();sync(self.progress*self.animation.duration())}
|
|
}
|
|
});
|
|
|
|
tl.addLabel("hero",0)
|
|
.to({},{duration:.3})
|
|
.addLabel("fly")
|
|
.to(word,{x:()=>-.68*innerWidth,y:()=>-.6*innerHeight,scale:.8,filter:blur(8),ease:ez("power2.in"),duration:.8},"fly")
|
|
.to(word,{autoAlpha:0,duration:.25,ease:"power2.in"},"fly+=.55")
|
|
.addLabel("trust","fly+=.8")
|
|
.to({},{duration:hold},"trust")
|
|
.addLabel("toSand")
|
|
.to(trust,{x:()=>-.06*innerWidth,y:()=>-.8*innerHeight,ease:ez("power2.in"),duration:.35},"toSand")
|
|
.to(trust,{keyframes:{filter:[blur(0),blur(12),blur(0)]},duration:.35},"toSand")
|
|
.to(trust,{autoAlpha:0,duration:.1},"toSand+=.25")
|
|
.fromTo(sand,{x:0,y:()=>innerHeight+30},{x:()=>-.14*innerWidth,y:()=>-720*sand.offsetWidth/2600,ease:ez("power1.inOut"),duration:.9},"toSand")
|
|
.to(sand,{keyframes:{filter:[blur(0),blur(7),blur(0)]},duration:.9},"toSand")
|
|
.addLabel("howto","toSand+=.9")
|
|
.to({},{duration:hold},"howto")
|
|
.addLabel("toLearn")
|
|
.to(howto.children,{y:()=>-.7*innerHeight,ease:ez("power2.in"),duration:.6},"toLearn")
|
|
.to(howto.children,{autoAlpha:0,duration:.15},"toLearn+=.42")
|
|
.to(sand,{x:()=>-.08*innerWidth,y:()=>-720*sand.offsetWidth/2600-1.8*innerHeight,ease:ez("power2.inOut"),duration:.9},"toLearn")
|
|
.to(sand,{keyframes:{filter:[blur(0),blur(9),blur(0)]},duration:.9},"toLearn")
|
|
.addLabel("learn","toLearn+=.9")
|
|
.to({},{duration:hold},"learn")
|
|
.addLabel("toSea")
|
|
.fromTo(seaState,{f:0},{f:1,ease:ez("sine.inOut"),duration:.9,onUpdate:drawSea},"toSea")
|
|
.addLabel("prog","toSea+=1")
|
|
.to({},{duration:hold},"prog")
|
|
.addLabel("toTeam")
|
|
.fromTo(iris,{"--r":"62vmax"},{"--r":"2vmax",ease:ez("power1.inOut"),duration:.9,immediateRender:false},"toTeam")
|
|
.fromTo(ring,{"--r":"62vmax"},{"--r":"2vmax",ease:ez("power1.inOut"),duration:.82,immediateRender:false},"toTeam")
|
|
.addLabel("team","toTeam+=1")
|
|
.to({},{duration:hold},"team")
|
|
.addLabel("toRev")
|
|
.to(team,{y:()=>-.55*innerHeight,ease:ez("power2.in"),duration:.8},"toRev")
|
|
.to(team,{keyframes:{filter:[blur(0),blur(10),blur(0)]},duration:.8},"toRev")
|
|
.fromTo(rev,{y:()=>innerHeight*1.12},{y:0,ease:ez("power1.inOut"),duration:.9},"toRev")
|
|
.addLabel("rev","toRev+=1")
|
|
.to({},{duration:hold},"rev")
|
|
.addLabel("toPrice")
|
|
.to(rev,{y:()=>-innerHeight,ease:ez("none"),duration:.9},"toPrice")
|
|
.fromTo(price,{y:()=>innerHeight},{y:0,ease:ez("none"),duration:.9},"toPrice")
|
|
.addLabel("price","toPrice+=1")
|
|
.to({},{duration:hold},"price");
|
|
if(sky){
|
|
tl.addLabel("toFaq")
|
|
.to(price.querySelectorAll(".pr__title,.pr__list,.pr__cta"),{y:()=>-innerHeight,ease:ez("power1.in"),duration:.55},"toFaq")
|
|
.fromTo(sky,{x:0,y:()=>innerHeight+30},{x:()=>.14*innerWidth,y:()=>-720*sky.offsetWidth/2600,ease:ez("power1.inOut"),duration:.9},"toFaq+=.3")
|
|
.to(sky,{keyframes:{filter:[blur(0),blur(7),blur(0)]},duration:.9},"toFaq+=.3")
|
|
.addLabel("faq","toFaq+=1.2");
|
|
}
|
|
stage.style.height=`${(tl.duration()*100).toFixed(0)}vh`;
|
|
ScrollTrigger.refresh();
|
|
|
|
const show=(el,d)=>{gsap.killTweensOf(el,"autoAlpha");gsap.to(el,{autoAlpha:1,duration:quick||rush?0:.35,delay:quick||rush?0:d,ease:"power1.out"})};
|
|
const hide=el=>{gsap.killTweensOf(el,"autoAlpha");gsap.to(el,{autoAlpha:0,duration:quick||rush?0:.2,ease:"power1.in"})};
|
|
const L=tl.labels;
|
|
const topbar=document.querySelector("[data-topbar]");
|
|
const navLinks=topbar?[...topbar.querySelectorAll(".topbar__link")]:[];
|
|
const waveNS="http://www.w3.org/2000/svg";
|
|
const navWaves=navLinks.map(link=>{
|
|
const svg=document.createElementNS(waveNS,"svg");
|
|
svg.classList.add("topbar__wave");
|
|
svg.setAttribute("aria-hidden","true");
|
|
svg.setAttribute("viewBox","0 0 100 40");
|
|
const contours=['M2 21 C18 12 30 12 49 20 C68 28 84 25 98 15 C87 29 69 31 48 24 C29 17 17 16 2 21Z', 'M11 26 C25 21 37 23 51 28 C64 32 75 33 86 30 C74 37 61 35 48 31 C34 26 23 24 11 26Z'];
|
|
contours.forEach(d=>{
|
|
const path=document.createElementNS(waveNS,"path");
|
|
path.setAttribute("d",d);svg.append(path);
|
|
});
|
|
link.append(svg);
|
|
return svg;
|
|
});
|
|
const zoneEls=topbar?[".topbar__brand",".topbar__nav",".topbar__cta"].map(q=>topbar.querySelector(q)).filter(Boolean):[];
|
|
const setZones=()=>{
|
|
if(!topbar)return;
|
|
const box=topbar.getBoundingClientRect(),w=box.width;
|
|
if(!w)return;
|
|
const pct=v=>Math.min(100,Math.max(0,v/w*100)).toFixed(2);
|
|
let last=0;
|
|
const stops=[];
|
|
zoneEls.forEach(el=>{
|
|
const r=el.getBoundingClientRect(),a=r.left-box.left-24,z=r.right-box.left+24;
|
|
stops.push(`#000 ${pct(last)}%`,`#000 ${pct(Math.max(last,a-40))}%`,`transparent ${pct(a)}%`,`transparent ${pct(z)}%`);
|
|
last=z+40;
|
|
});
|
|
stops.push(`#000 ${pct(last)}%`,"#000 100%");
|
|
topbar.style.setProperty("--zones",`linear-gradient(90deg,${stops.join(",")})`);
|
|
};
|
|
setZones();
|
|
addEventListener("resize",setZones);
|
|
if(document.fonts)document.fonts.ready.then(setZones);
|
|
let activeNav=-1;
|
|
const setNavWave=key=>{
|
|
const next=navLinks.findIndex(link=>link.dataset.stageLink===key);
|
|
if(next===activeNav)return;
|
|
const direction=next<0||next<activeNav?-1:1;
|
|
const reduced=matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
navWaves.forEach((wave,index)=>{
|
|
const visible=index===next;
|
|
const wasVisible=index===activeNav;
|
|
if(!visible&&!wasVisible){
|
|
wave.getAnimations().forEach(animation=>animation.cancel());
|
|
wave.style.clipPath="inset(0 100% 0 0)";
|
|
return;
|
|
}
|
|
const from=visible&&!wasVisible
|
|
?(direction>0?"inset(0 100% 0 0)":"inset(0 0 0 100%)")
|
|
:getComputedStyle(wave).clipPath;
|
|
const to=visible?"inset(0 0 0 0)"
|
|
:(direction>0?"inset(0 0 0 100%)":"inset(0 100% 0 0)");
|
|
wave.getAnimations().forEach(animation=>animation.cancel());
|
|
wave.style.clipPath=to;
|
|
if(!reduced)wave.animate([{clipPath:from},{clipPath:to}],{
|
|
duration:700,easing:"cubic-bezier(.25,.65,.3,1)"
|
|
});
|
|
});
|
|
activeNav=next;
|
|
};
|
|
const marks=[["prog",L.toSea+.97],["team",L.toTeam+.9],["rev",L.toRev+.05],["price",L.toPrice+.02],...(sky?[["faq",L.toFaq+1.15]]:[])];
|
|
const targets={hero:0};
|
|
["prog","team","rev","price"].forEach(k=>{if(L[k]!==undefined)targets[k]=L[k]+Math.max(hold/2,.05)});
|
|
document.querySelectorAll("[data-stage-link]").forEach(link=>link.addEventListener("click",event=>{
|
|
const key=link.dataset.stageLink,section=key==="faq"?document.getElementById("faq"):null;
|
|
const time=targets[key];
|
|
if(time===undefined&&!section)return;
|
|
event.preventDefault();
|
|
const y=section?section.getBoundingClientRect().top+scrollY-(topbar?topbar.offsetHeight:0):st.start+time/tl.duration()*(st.end-st.start);
|
|
setRush(true);
|
|
if(lenis)lenis.scrollTo(y,{immediate:true,force:true});else scrollTo({top:y,behavior:"auto"});
|
|
setRush(true,400);
|
|
}));
|
|
const rules=[
|
|
[trustIn,L.fly+.78,L.toSand+.8],
|
|
[howto,L.toSand+.8,L.toLearn+.8],
|
|
[learn,L.toLearn+.8,L.toSea+.97],
|
|
[prog,L.toSea+.97,L.toTeam+.9],
|
|
[team,L.toTeam+.9,Infinity],
|
|
[rev,L.toRev+.05,Infinity],
|
|
[price,L.toPrice+.02,Infinity],
|
|
];
|
|
const shown=new Map(rules.map(r=>[r[0],false]));
|
|
const faqSection=document.querySelector("[data-faq]");
|
|
const footEl=document.querySelector(".foot");
|
|
const setFootH=()=>{if(footEl)document.documentElement.style.setProperty("--foot-h",`${footEl.offsetHeight}px`)};
|
|
setFootH();
|
|
addEventListener("resize",setFootH);
|
|
if(footEl&&window.ResizeObserver)new ResizeObserver(setFootH).observe(footEl);
|
|
const plays=[[trust,"trust--play",L.fly+.8],[howto,"howto--play",L.toSand+.85],[learn,"learn--play",L.toLearn+.85],[prog,"prog--play",L.toSea+.97],[rev,"rev--play",L.toRev+.85],[price,"pr--play",L.toPrice+.6]];
|
|
const stageLinks=topbar?[...topbar.querySelectorAll("[data-stage-link]")]:[];
|
|
let fadeLevel=-1,navKey,topOn,heroDone=false;
|
|
sync=time=>{
|
|
now=time;
|
|
if(time>L.fly){
|
|
hero.classList.add("soft--fly");
|
|
if(!heroDone){heroDone=true;hero.getAnimations({subtree:true}).forEach(x=>{if(x.playState!=="finished")x.finish()})}
|
|
}
|
|
const fade=Math.round(Math.min(1,Math.max(0,(time-L.fly)/.25))*100)/100;
|
|
if(fade!==fadeLevel){fadeLevel=fade;if(fade===0&&!hero.classList.contains("soft--fly"))gsap.set(fades,{clearProps:"opacity,visibility"});else gsap.set(fades,{autoAlpha:1-fade})}
|
|
plays.forEach(([el,cls,from])=>{if(time>=from&&!el.classList.contains(cls))el.classList.add(cls)});
|
|
if(faqSection&&sky){
|
|
const onSky=time>=L.toFaq+.75;
|
|
if(onSky)faqSection.classList.add("faq--play");
|
|
faqSection.classList.toggle("faq--away",!onSky);
|
|
}
|
|
if(time>=L.toTeam+.9)teamEnter();
|
|
else if(teamTl){teamTl.progress(1);teamTl=null}
|
|
rules.forEach(([el,from,to],n)=>{
|
|
const want=time>=from&&time<to;
|
|
if(shown.get(el)===want)return;
|
|
shown.set(el,want);
|
|
if(want){
|
|
const swap=n>0&&rules[n-1][2]===from;
|
|
show(el,swap?.12:0);
|
|
}else hide(el);
|
|
});
|
|
let top=null;
|
|
rules.forEach(([el])=>{if(shown.get(el))top=el});
|
|
rules.forEach(([el])=>{const off=el!==top;if(el.inert!==off)el.inert=off});
|
|
prog.classList.toggle("prog--live",shown.get(prog));
|
|
iris.classList.toggle("stage__iris--closed",time>=L.toTeam+.9);
|
|
if(topbar){
|
|
const on=time>=L.fly+.8;
|
|
if(on!==topOn){topOn=on;topbar.classList.toggle("topbar--on",on)}
|
|
const current=[...marks].reverse().find(([,from])=>time>=from);
|
|
const key=current?.[0];
|
|
if(key!==navKey){
|
|
navKey=key;
|
|
setNavWave(key);
|
|
stageLinks.forEach(link=>{
|
|
const active=link.dataset.stageLink===key;
|
|
link.classList.toggle("topbar__link--active",active);
|
|
if(active)link.setAttribute("aria-current","true");else link.removeAttribute("aria-current");
|
|
});
|
|
}
|
|
}
|
|
};
|
|
const st=tl.scrollTrigger;
|
|
sync(st.progress*tl.duration());
|
|
if(!quick){stage.classList.add("stage--ready");root.classList.add("is-ready")}
|
|
let keep=null;
|
|
addEventListener("resize",()=>{if(keep===null)keep=st.progress});
|
|
ScrollTrigger.addEventListener("refresh",()=>{
|
|
if(keep===null)return;
|
|
const y=st.start+keep*(st.end-st.start);
|
|
keep=null;
|
|
setRush(true,400);
|
|
if(lenis)lenis.scrollTo(y,{immediate:true,force:true});else scrollTo(0,y);
|
|
});
|
|
|
|
const ready=()=>{
|
|
ScrollTrigger.refresh();
|
|
if(quick&&scrollY===0){
|
|
hero.querySelectorAll(".soft__glyph--done").forEach(g=>g.classList.remove("soft__glyph--done"));
|
|
hero.getAnimations({subtree:true}).forEach(a=>{a.currentTime=0;a.play()});
|
|
}else if(quick)finishAll();
|
|
requestAnimationFrame(()=>requestAnimationFrame(()=>{quick=false;stage.classList.add("stage--ready");root.classList.add("is-ready");stage.classList.remove("stage--boot")}));
|
|
};
|
|
if(document.readyState==="complete")ready();else addEventListener("load",ready);
|
|
})();
|