-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.min.js
1 lines (1 loc) · 9.1 KB
/
script.min.js
1
const initialStyles=new WeakMap;function saveInitialStyles(e){let t=window.getComputedStyle(e);initialStyles.set(e,{transform:t.transform||"rotateX(0deg) rotateY(0deg) scale(1)",mx:t.getPropertyValue("--mx").trim()||"0%",my:t.getPropertyValue("--my").trim()||"0%",s:t.getPropertyValue("--s").trim()||"1",o:t.getPropertyValue("--o").trim()||"1",pos:t.getPropertyValue("--pos").trim()||"0% 0%",posx:t.getPropertyValue("--posx").trim()||"0%",posy:t.getPropertyValue("--posy").trim()||"0%",hyp:t.getPropertyValue("--hyp").trim()||"0",galaxybg:t.getPropertyValue("--galaxybg").trim()||"initial"})}function OrientCard(e){let t=e.currentTarget,a=t.getBoundingClientRect(),o=a.left+a.width/2,i=a.top+a.height/2,n=e.clientX-o,s=e.clientY-i,l=clamp(-s/(a.height/2)*15,-15,15),r=clamp(n/(a.width/2)*15,-15,15);gsap.to(t,{duration:.5,transform:`rotateX(${l}deg) rotateY(${r}deg) scale(1.05)`,"--mx":`${40-2.5*r}%`,"--my":`${5+l/2}%`,"--pos":`${2.5*r}% ${.5*l}%`,"--posx":`${50+r/2+.5*l}%`,"--posy":`${50+l/2+r/2}%`,"--hyp":`${Math.min(Math.max(Math.sqrt(n*n+s*s)/50,0),1)}`,ease:"power4.out"})}function handleMouseLeave(e){let t=e.currentTarget,a=initialStyles.get(t);a&&gsap.to(t,{duration:.5,transform:a.transform,"--mx":a.mx,"--my":a.my,"--pos":a.pos,"--posx":a.posx,"--posy":a.posy,"--hyp":a.hyp,"--scale":a.s,ease:"power4.inOut"})}function clamp(e,t=-20,a=20){return Math.min(Math.max(e,t),a)}function orientationhandler(e){let t=e.alpha,a=e.beta,o=e.gamma;gsap.to(".card",{duration:.5,transform:`rotateX(${a}deg) rotateY(${o}deg) rotateZ(${t}deg)`,ease:"power2.out",overwrite:!0})}function adaptCardType(e){Array.from(document.getElementsByClassName("card")).forEach(t=>{t.setAttribute("data-rarity",e.value)})}document.addEventListener("DOMContentLoaded",()=>{window.DeviceOrientationEvent&&"ontouchstart"in window&&(window.addEventListener("deviceorientation",orientationhandler,!1),window.addEventListener("MozOrientation",orientationhandler,!1)),document.querySelectorAll(".card").forEach(e=>{saveInitialStyles(e),e.addEventListener("mousemove",e=>{OrientCard(e)}),e.addEventListener("mouseleave",handleMouseLeave)})}),document.addEventListener("DOMContentLoaded",function(){let e=document.getElementById("category-filter"),t=document.querySelector(".card-grid");e.addEventListener("change",function(){let a=e.value;(function e(a){let o=Array.from(t.querySelectorAll(".holographic__section"));o.forEach(e=>{let t=e.querySelector(".card").getAttribute("data-category");"all"===a||t===a?e.style.display="":e.style.display="none"})})(a)})}),document.addEventListener("DOMContentLoaded",function(){let e=document.querySelector("button img[alt='Grid 1']").parentElement,t=document.querySelector("button img[alt='Grid 2']").parentElement,a=document.querySelector("button img[alt='Grid 3']").parentElement,o=document.querySelector(".card-grid");function i(i){switch(o.classList.remove("layout-1","layout-2","layout-3"),e.classList.remove("active"),t.classList.remove("active"),a.classList.remove("active"),i){case 1:o.classList.add("layout-1"),e.classList.add("active");break;case 2:o.classList.add("layout-2"),t.classList.add("active");break;case 3:o.classList.add("layout-3"),a.classList.add("active")}}i(1),e.addEventListener("click",()=>i(1)),t.addEventListener("click",()=>i(2)),a.addEventListener("click",()=>i(3))}),document.addEventListener("DOMContentLoaded",function(){Fancybox.bind('[data-fancybox="gallery"]',{})}),$(document).ready(function(){var e,t,a,o,i;function n(e){$(".slide.active").data("slide")!==e&&($(".slide").removeClass("active"),$(".slide[data-slide="+e+"]").addClass("active"),$(".nav-dot").removeClass("active loading"),$(".nav-dot[data-slide="+e+"]").addClass("active loading"))}function s(){e=setInterval(function(){var e=$(".slide.active");e.data("slide"),n(e.next(".slide").length?e.next(".slide").data("slide"):$(".slide").first().data("slide"))},1e4)}function l(){clearInterval(e)}$(".nav-dot").on("click",function(e){e.preventDefault(),n($(this).data("slide")),l(),s()}),$(".carousel-wrapper").on("touchstart mousedown",function(e){"touchstart"===e.type?(t=e.originalEvent.touches[0].pageX,a=e.originalEvent.touches[0].pageY):(t=e.pageX,a=e.pageY,e.preventDefault()),l()}),$(".carousel-wrapper").on("touchend mouseup",function(e){"touchend"===e.type?(o=e.originalEvent.changedTouches[0].pageX,i=e.originalEvent.changedTouches[0].pageY):(o=e.pageX,i=e.pageY);var l=o-t;if(Math.abs(l)>Math.abs(i-a)){if(l>50){var r=$(".slide.active");n(r.prev(".slide").length?r.prev(".slide").data("slide"):$(".slide").last().data("slide"))}else if(l<-50){var r=$(".slide.active");n(r.next(".slide").length?r.next(".slide").data("slide"):$(".slide").first().data("slide"))}}s()}),n($(".nav-dot.active").data("slide")),$(".nav-dot.active").addClass("loading"),s()});var cursor=$(".cursor"),follower=$(".cursor-follower"),posX=0,posY=0,mouseX=0,mouseY=0;function moveCursor(){posX+=(mouseX-posX)/9,posY+=(mouseY-posY)/9,follower.css({left:`${posX-1}px`,top:`${posY-1}px`}),cursor.css({left:`${mouseX}px`,top:`${mouseY}px`}),requestAnimationFrame(moveCursor)}function handleCursorVisibility(){window.innerWidth<=991?(cursor.hide(),follower.hide()):(cursor.show(),follower.show())}requestAnimationFrame(moveCursor),$(document).on("mousemove",function(e){mouseX=e.clientX,mouseY=e.clientY}),$(document).on("mousedown",function(){cursor.addClass("active"),follower.addClass("active")}),$(document).on("mouseup",function(){cursor.removeClass("active"),follower.removeClass("active")}),$(window).on("resize",handleCursorVisibility),$(window).on("load",handleCursorVisibility),handleCursorVisibility(),document.addEventListener("DOMContentLoaded",()=>{let e=document.getElementById("darkModeToggle"),t=document.querySelector("body"),a=document.getElementById("lottieLight"),o=document.getElementById("lottieDark"),i=document.getElementById("logoLight"),n=document.getElementById("logoDark"),s,l,r=-1,d=-1;function c(){s=lottie.loadAnimation({container:a,renderer:"svg",loop:!1,autoplay:!1,path:"/src/assets/Animations/lottiewhite.json"}),l=lottie.loadAnimation({container:o,renderer:"svg",loop:!1,autoplay:!1,path:"/src/assets/Animations/lottieblack.json"});let e=e=>{e.goToAndStop(e.totalFrames-1,!0)};s.addEventListener("DOMLoaded",()=>e(s)),l.addEventListener("DOMLoaded",()=>e(l))}function u(){t.classList.contains("dark-mode")?(a.style.display="none",o.style.display="block",i.style.display="block",n.style.display="none",l.setDirection(d),l.play(),d=-d):(o.style.display="none",a.style.display="block",i.style.display="none",n.style.display="block",s.setDirection(r),s.play(),r=-r),t.classList.toggle("dark-mode")}let y=(e,t)=>{let a;return(...o)=>{clearTimeout(a),a=setTimeout(()=>e.apply(this,o),t)}},p=y(()=>{s.setDirection(r),s.play(),r=-r},200),m=y(()=>{l.setDirection(d),l.play(),d=-d},200);a.addEventListener("click",p),o.addEventListener("click",m),l?(i.style.display="block",n.style.display="none"):(i.style.display="none",n.style.display="block"),e.addEventListener("click",u),c(),t.classList.add("dark-mode"),a.style.display="block",o.style.display="none",i.style.display="none",n.style.display="block"}),document.addEventListener("DOMContentLoaded",()=>{let e=document.querySelector(".top_navigation_container"),t=()=>{window.scrollY>35?e.classList.add("scrolled"):e.classList.remove("scrolled")};window.addEventListener("scroll",()=>{requestAnimationFrame(t)})}),document.addEventListener("DOMContentLoaded",function(){var e=gsap.timeline({paused:!0});e.to(".menu-left",{duration:.8,left:0,ease:"power4.out"}).staggerFrom(".menu__item",.6,{y:50,opacity:0,ease:"power4.out"},.1,"-=0.5"),e.reverse(),document.querySelector(".hamburger").addEventListener("click",function(){e.reversed(!e.reversed())})});var btn=$(".btn");function disableScroll(){document.documentElement.style.overflow="hidden"}function enableScroll(){document.documentElement.style.overflow="auto"}function isHomePage(){let e=window.location.pathname,t=e.substring(e.lastIndexOf("/")+1);return"index.html"===t||""===t}function startLoadingAnimation(){disableScroll(),gsap.fromTo(".loading-page",{opacity:1,visibility:"visible"},{opacity:0,visibility:"hidden",duration:1.5,delay:2.5,ease:"power2.out",onComplete:enableScroll}),gsap.fromTo(".logo-name",{y:50,opacity:0},{y:0,opacity:1,duration:2,delay:.5,ease:"back.out(1.7)"})}btn.on("click",function(){var e=$(this);e.hasClass("active")?e.removeClass("active").addClass("not-active"):e.removeClass("not-active").addClass("active")}),isHomePage()&&setTimeout(function(){document.querySelector(".loading-page").classList.add("hidden"),startLoadingAnimation()},0),document.addEventListener("DOMContentLoaded",function(){gsap.registerPlugin();let e=document.querySelectorAll(".footer-link");e.forEach(e=>{let t=e.querySelector(".hover-line-fill");e.addEventListener("mouseenter",()=>{gsap.to(t,{scaleX:1,width:"100%",duration:.4,ease:"power3.out"})}),e.addEventListener("mouseleave",()=>{gsap.to(t,{scaleX:0,width:"0%",duration:.4,ease:"power3.in"})})})}),gsap.fromTo(".socialicons",{scale:1},{scale:1.2,duration:.2,ease:"power1.out",paused:!0}),document.querySelectorAll(".socialicons").forEach(e=>{e.addEventListener("mouseenter",()=>{gsap.to(e,{scale:1.2,duration:.1,ease:"power2.out"})}),e.addEventListener("mouseleave",()=>{gsap.to(e,{scale:1,duration:.1,ease:"power2.in"})})});