$(async function () { $(".service_process_tabs>div").click(function () { $(this).addClass("activeTabs").siblings().removeClass("activeTabs"); let id = $(this).data("type"); $(".service_process_text").children().eq(id).show().siblings().hide(); }); /* */ function amit() { let radius = 400; // how big of the radius let autoRotate = true; // auto rotate or not let rotateSpeed = -60; // unit: seconds/360 degrees let imgWidth = 250; // width of images (unit: px) let imgHeight = 300; // height of images (unit: px) setTimeout(init, 100); let odrag = document.getElementById("drag-container"); let ospin = document.getElementById("spin-container"); let aImg = ospin.getElementsByTagName("img"); let aVid = ospin.getElementsByTagName("video"); let aEle = [...aImg, ...aVid]; // combine 2 arrays // Size of images ospin.style.width = imgWidth + "px"; ospin.style.height = imgHeight + "px"; // Size of ground - depend on radius let ground = document.getElementById("ground"); ground.style.width = radius * 3 + "px"; ground.style.height = radius * 3 + "px"; function init(delayTime) { for (let i = 0; i < aEle.length; i++) { aEle[i].style.transform = "rotateY(" + i * (360 / aEle.length) + "deg) translateZ(" + radius + "px)"; aEle[i].style.transition = "transform 1s"; aEle[i].style.transitionDelay = delayTime || (aEle.length - i) / 4 + "s"; } } function applyTranform(obj) { // Constrain the angle of camera (between 0 and 180) if (tY > 180) tY = 180; if (tY < 0) tY = 0; // Apply the angle obj.style.transform = "rotateX(" + -tY + "deg) rotateY(" + tX + "deg)"; } function playSpin(yes) { ospin.style.animationPlayState = yes ? "running" : "paused"; } let sX, sY, nX, nY, desX = 0, desY = 0, tX = 0, tY = 10; // auto spin if (autoRotate) { let animationName = rotateSpeed > 0 ? "spin" : "spinRevert"; ospin.style.animation = `${animationName} ${Math.abs( rotateSpeed )}s infinite linear`; } // setup events document.onpointerdown = function (e) { clearInterval(odrag.timer); e = e || window.event; let sX = e.clientX, sY = e.clientY; this.onpointermove = function (e) { e = e || window.event; let nX = e.clientX, nY = e.clientY; desX = nX - sX; desY = nY - sY; tX += desX * 0.1; tY += desY * 0.1; applyTranform(odrag); sX = nX; sY = nY; }; this.onpointerup = function (e) { odrag.timer = setInterval(function () { desX *= 0.95; desY *= 0.95; tX += desX * 0.1; tY += desY * 0.1; applyTranform(odrag); playSpin(false); if (Math.abs(desX) < 0.5 && Math.abs(desY) < 0.5) { clearInterval(odrag.timer); playSpin(true); } }, 17); this.onpointermove = this.onpointerup = null; }; }; // document.onmousewheel = function (e) { // e = e || window.event; // let d = e.wheelDelta / 20 || -e.detail; // radius += d; // init(1); // }; } $(".activity>div>div").on("click", "a", function () { $(this).addClass("activeSwiper").siblings().removeClass("activeSwiper"); swiper.slideTo(Number.parseInt($(this).data("type")) + 1, 1000, false); }); // if (!localStorage.getItem('statement')) { // $("body,html").css("overflow", "hidden"); // } $("#statement .cancel").click(function () { $("#statement").hide(); localStorage.setItem("statement", true); $("body,html").css("overflow", "auto"); }); });