/*----------------------------------------------- * SCROOL BY LENIS -------------------------------------------------*/ const lenis = new Lenis() // lenis.on('scroll', (e) => { // console.log(e) // }) function raf(time) { lenis.raf(time) requestAnimationFrame(raf) } requestAnimationFrame(raf) /*----------------------------------------------- * MOVIE ASPECT -------------------------------------------------*/ let aspect = 16/9; function moviebg_size(){ let wiw = window.innerWidth; wih = window.innerHeight; minww = wiw; minwh = wih; mw = wiw / 2; mh = wih; if(mw <= wiw){ mw = minww; } if(mh <= minwh){ mh = minwh; } // BG SIZE if(mw/mh <= aspect){ $(".js-movieBg__cont").css({"height":mh+"px","width":mh*aspect+"px"}); }else{ $(".js-movieBg__cont").css({"height":mw/aspect+"px","width":mw+"px"}); } // MIN let p_movFrame__width = wiw * 0.711667; let p_movFrame__height = wih * 0.75; if(wiw > 768){ // PC if(p_movFrame__width / p_movFrame__height > aspect){ // PC - Horizontal $(".js-movieBgIn").css({ 'min-height': p_movFrame__height + 'px', 'min-width': p_movFrame__height * aspect + 'px' }); }else{ // PC - Vertical $(".js-movieBgIn").css({ 'min-height': p_movFrame__width / aspect + 'px', 'min-width': p_movFrame__width + 'px' }) } } } /*----------------------------------------------- * VIEW CHANGE -------------------------------------------------*/ function viewChange(){ // Check gyro sensor var isGyro = false; if ((window.DeviceOrientationEvent) && ('ontouchstart' in window)) { isGyro = true; } //PC and more NOTUSE gyro sensor if (!isGyro) { tiltJS_play(); // gyro Device } else { //gyro motion Check var resGyro = false; window.addEventListener("deviceorientation", doGyro, false); function doGyro() { resGyro = true; window.removeEventListener("deviceorientation", doGyro, false); } setTimeout(function () { //ジャイロが動作する場合 if (resGyro) { tiltJS_play(); //ジャイロが動作しない場合 } else { //iOS13以上ならクリックイベントを要求 if (typeof DeviceOrientationEvent.requestPermission === "function") { //ユーザアクションを得るための要素を表示 DeviceOrientationEvent.requestPermission().then(res => { //「動作と方向」が許可された if (res === "granted") { tiltJS_play(); //「動作と方向」が許可されなかった } else { isGyro = false; tiltJS_play(); } }); //iOS13以上ではない場合 } else { isGyro = false; tiltJS_play(); } } }, 300); } } function tiltJS_play(){ let isPC = window.matchMedia('(min-width: 768px)').matches; if(isPC){ // alert('PC'); VanillaTilt.init(document.querySelectorAll(".js-tilt_header"), { reverse: true, perspective: 1000, max: 4, speed: 800 }); VanillaTilt.init(document.querySelectorAll(".js-tilt_content"), { reverse: true, perspective: 1500, max: 4, speed: 800 }); }else{ VanillaTilt.init(document.querySelectorAll(".js-tilt_header"), { reverse: true, perspective: 1000, max: 16, speed: 800 }); VanillaTilt.init(document.querySelectorAll(".js-tilt_content"), { reverse: true, perspective: 2000, max: 16, speed: 800 }); } } function viewChange_action(){ if($("body").hasClass('--mode-tilt')){ vanillaTiltDestroy(); $("body").removeClass('--mode-tilt'); viewChange_chk = false; }else{ viewChange(); $("body").addClass('--mode-tilt'); viewChange_chk = true; } } function vanillaTiltDestroy(){ document.querySelector(".js-tilt_header").vanillaTilt.destroy(); document.querySelector(".js-tilt_content").vanillaTilt.destroy(); } /*----------------------------------------------- * COMMON ACTION -------------------------------------------------*/ // resizeEVENT function resize(){ // MOVIE moviebg_size(); } window.addEventListener('resize', resize); function load(){ moviebg_size(); movieBGVideoPlayer('play'); } window.addEventListener('load', load); /*----------------------------------------------- * LO -------------------------------------------------*/ $("body").css({'overflow':'hidden'}); $(window).on('load',function(){ setTimeout(function(){ $("body").addClass('--is-load'); setTimeout(function(){ $("#loading").fadeOut(600); setTimeout(function(){ $("body").addClass('--is-loaded'); $("body").css({'overflow':''}); },200); },600); },800); });