"use strict"; var $win = $(window); var $windowHeight = $win.innerHeight(); var $windowWidth = $win.innerWidth(); $win.on("load",function(){ //console.log("window onload"); $("#load").fadeOut(400, "linear"); if(typeof pageInitFunction == "function") { pageInitFunction(); } }); // anchor $(function () { var headSize = $(".globalHeader").outerHeight() + 20; $('a[href^="#"]').on("click", function (e) { var href = $(this).attr("href"); var target = $(href == "#" || href == "" ? 'html' : href); var position = target.offset().top - headSize; $.when( $("html, body").animate({ scrollTop: position }, 400, "swing"), e.preventDefault(), ).done(function () { var diff = target.offset().top - headSize; if (diff === position) { } else { $("html, body").animate({ scrollTop: diff }, 10, "swing"); } }); }); // $("#load").fadeOut(400, "linear"); // HOME/TOP LINE追加でクーポンの表示制御 if(sessionStorage.getItem('line_follow_close')) { $("#lineFollowBox").remove(); // セッションに、閉じるボタンを押した記録があればポップアップを削除 } if(sessionStorage.getItem('app_install_close')) { $("#appInstallBox").remove(); // セッションに、閉じるボタンを押した記録があればポップアップを削除 } }); // lazy load images function lazyImages() { var scroll = $win.scrollTop(); var windowHeight = $win.height(); $("img[data-src]").each(function() { var imgPos = $(this).offset().top; if (scroll > imgPos - $windowHeight - ($windowHeight - 100)) { var image = $(this).data("src"); $(this).attr("src", image); $(this).removeAttr("data-src"); } }); $("source[data-srcset]").each(function() { var imgPos = $(this).offset().top; if (scroll > imgPos - $windowHeight - ($windowHeight - 100)) { var image = $(this).data('srcset'); $(this).attr('srcset', image); $(this).removeAttr('data-srcset'); } }); } // 追従バナー $win.on("scroll", function() { var scroll = $win.scrollTop(); var docHeight = $(document).height(); var scrollPos = $win.height() + scroll; var follow = $(".followBox"); var footer = $(".footer").height(); if (docHeight - scrollPos <= footer) { follow.removeClass("is-show"); } else if (scroll > 100) { follow.addClass("is-show"); } else { follow.removeClass("is-show"); } }); $("#lineFollowBox_close").on("click", function() { sessionStorage.setItem('line_follow_close', 'on'); // 閉じた情報をセッションに保存 $("#lineFollowBox").remove(); }); $("#appInstallBox_close").on("click", function() { sessionStorage.setItem('app_install_close', 'on'); // 閉じた情報をセッションに保存 $("#appInstallBox").remove(); }); $win.on("load scroll", function() { lazyImages(); }); // html側でaddImageがある場合の対策 lazyImages()に以降が完了したら削除 var addImage = (type) => { lazyImages(); } // lazyImages()に以降が完了したら削除 ここまで //toolbar $(".toolBtn").each(function(){ var $href = $(this).attr("href"); if(location.href.match($href)) { $(this).parent().addClass("-current"); } else if (location.href.match("t-shirt|iphone-case|tote|hoodie|acryl-key")) { $(".barMenu_item").eq(0).addClass("-current"); } else { $(this).parent().removeClass("-current"); } }); //navigation bar $(".navList_item a").each(function(){ var $href = $(this).attr("href"); if(location.href.match($href)) { $(this).parent().addClass("-current"); } else { $(this).parent().removeClass("-current"); } }); $(".navList_item").each(function(){ if ($(this).hasClass("-current")) { } }); //acc table view $(".selectToggle").on("click", function() { if($("+ .tableView", this).css("display") == "none") { $(this).addClass("is-open"); $("+ .tableView", this).slideDown(300); } else if($("+ .tableView").hasClass("-opened")) { $(this).removeClass("-opened"); } else { $(this).removeClass("is-open"); $("+ .tableView", this).slideUp(300); } }); //product detail acc $win.on("load resize", function() { if ($windowWidth <= 820) { $(".accHead").off('click'); $(".accHead").on("click", function() { if($("+ .accInner", this).css("display") == "none") { console.log("open"); $(this).addClass("is-open"); $("+ .accInner", this).slideDown(300); } else { console.log("close"); $(this).removeClass("is-open"); $("+ .accInner", this).slideUp(300); } }); } }); let scrollPosition; const ua = window.navigator.userAgent.toLowerCase(); const isiOS = ua.indexOf('iphone') > -1 || ua.indexOf('ipad') > -1 || ua.indexOf('macintosh') > -1 && 'ontouchend' in document; const body = document.querySelector('body'); function bodyFixedOn() { if(isiOS){ scrollPosition = window.pageYOffset; body.style.position = 'fixed'; body.style.top = `-${scrollPosition}px`; } else { body.style.overflow = 'hidden'; } } function bodyFixedOff() { if(isiOS){ body.style.removeProperty('position'); body.style.removeProperty('top'); window.scrollTo(0, scrollPosition); } else { body.style.removeProperty('overflow'); } }