jscss

customize.js

//headerwrapに高さを転記 $(function() { var timer = false; $(window).on('load', function() { var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; if(windowWidth <= 1024) { //$('.header__layout1').css('position','fixed'); $(".header__float").addClass("is_float"); } else { //$('#header__layout1').css('position','absolute'); $(".header__float").removeClass("is_float"); var headerHeight = parseInt($('.header__layout').innerHeight()); } resizeHeaderHeight(); }); $(window).on('resize', function() { if (timer !== false) { clearTimeout(timer); } timer = setTimeout(function() { resizeHeaderHeight(); }, 200); }); function resizeHeaderHeight() { var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var targetBox = $('.header__wrap'); var headerHeight = $.isEmptyObject($('.header__layout')) ? 0 : $('.header__layout').innerHeight(); console.log(headerHeight); targetBox.css('height', headerHeight + 'px'); } }); // pcヘッダー $(function(){ if(window.matchMedia( '(min-width: 1025px)' ).matches){ var headerHeight = $('.header__wrap').outerHeight(); $(window).scroll(function(){ if($(window).scrollTop() >= headerHeight){ $(".header__float").addClass("is_float"); }else{ $(".header__float").removeClass("is_float"); } }); } }); $('.mv__slider').slick({ accessibility: false, autoplay: true, autoplaySpeed: 5000, speed: 1000, // 切り替えのアニメーション。ease,linear,ease-in,ease-out,ease-in-out cssEase: 'ease', dots: false, fade: true, arrows: false, infinite: true, initialSlide: 0, lazyLoad: 'ondemand', slidesToShow: 1, // 一度にスライドする数 slidesToScroll: 1, swipe: true, vertical: false, // 表示中の画像を中央へ centerMode: true }); $('.top-showroom__slider').slick({ accessibility: false, autoplay: true, autoplaySpeed: 5000, speed: 1000, // 切り替えのアニメーション。ease,linear,ease-in,ease-out,ease-in-out cssEase: 'ease', dots: true, fade: true, arrows: true, infinite: true, initialSlide: 0, lazyLoad: 'ondemand', slidesToShow: 1, // 一度にスライドする数 slidesToScroll: 1, swipe: true, vertical: false, // 表示中の画像を中央へ centerMode: true, appendArrows:'.top-showroom .slick-nav', appendDots:'.top-showroom .slick-customdots', prevArrow:'', nextArrow:'' }); $('.top-column__slider').slick({ dots: true, arrows: true, infinite: true, slidesToShow: 3, autoplay:true, appendArrows:'.top-column .slick-nav', appendDots:'.top-column .slick-customdots', prevArrow:'', nextArrow:'', responsive:[ { breakpoint: 1024, settings:{ slidesToShow: 3, } }, { breakpoint: 767, settings:{ autoplay: true, slidesToShow: 1, autoplaySpeed: 2500, speed: 800, dots: true, arrows: true, centerMode: true, centerPadding: '15%', } } ] }); $('.lp-modelroom__slider').slick({ accessibility: false, autoplay: true, autoplaySpeed: 5000, speed: 1000, // 切り替えのアニメーション。ease,linear,ease-in,ease-out,ease-in-out cssEase: 'ease', dots: true, fade: true, arrows: false, infinite: true, initialSlide: 0, lazyLoad: 'ondemand', slidesToShow: 1, // 一度にスライドする数 slidesToScroll: 1, swipe: true, vertical: false, // 表示中の画像を中央へ centerMode: true }); //SPメニュー $(function(){ $(".header__sp-menu").on('click',function(){ $(".global-nav").fadeIn(); }); //閉じるボタン $(".global-nav__close").on('click',function(){ $(".global-nav").fadeOut(); }); }); //PCグローバルナビ フローティング //フローティング //初期は非表示 $(function() { var topBtn = $('.float-side'); topBtn.hide(); //スクロールが100に達したらボタン表示 $(window).scroll(function () { if ($(this).scrollTop() > 100) { topBtn.fadeIn(); } else { topBtn.hide(); } }); }); //アンカー $(function(){ $('a[href*="#"]').click(function(){ var speed = 500; var href= $(this).attr('href'); var url = location.protocol + '//' + location.hostname + location.pathname; href = href.replace(url, ''); var target = $(href == '#' || href == '' ? 'html' : href); if( target.size() < 1 ) return true; var position = target.offset().top; $('html, body').animate({scrollTop:position}, speed, 'swing'); return false; }); }); //アコーディオン $(function(){ $('.js-accordion').off('click'); $('.js-accordion').on('click',function() { $(this).stop().toggleClass('active'); $(this).nextAll('.toggle:first').stop().slideToggle(300); //console.log('hoge'); }); }); //画像切り替え /* 画像切り替え-pcとsp- */ $(function () { const $setElem = $('.switch'), pcName = '_pc', spName = '_sp', replaceWidth = 769; $setElem.each(function () { const $this = $(this); function imgSize() { const windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; if (windowWidth >= replaceWidth) { $this.attr('src', $this.attr('src').replace(spName, pcName)).css({visibility: 'visible'}); } else if (windowWidth < replaceWidth) { $this.attr('src', $this.attr('src').replace(pcName, spName)).css({visibility: 'visible'}); } } $(window).resize(function () { imgSize(); }); imgSize(); }); }); //TOP line $(function(){ $(window).on('load scroll',function (){ $('.js-line').each(function(){ var target = $(this).offset().top; var scroll = $(window).scrollTop(); var windowHeight = $(window).height(); //console.log('target:'+target+' scrol:'+scroll+' winheight:'+windowHeight); if (scroll > target - windowHeight){ $(this).addClass("add"); } }); $('.js-line2').each(function(){ var target = $(this).offset().top; var scroll = $(window).scrollTop(); var windowHeight = $(window).height(); //console.log('target:'+target+' scrol:'+scroll+' winheight:'+windowHeight); if (scroll > target - windowHeight - 500){ $(this).addClass("add"); } }); }); }); //IE スムーススクロール停止 if(navigator.userAgent.match(/MSIE 10/i) || navigator.userAgent.match(/Trident\/7\./) || navigator.userAgent.match(/Edge\/12\./)) { $('body').on("mousewheel", function () { event.preventDefault(); var wd = event.wheelDelta; var csp = window.pageYOffset; window.scrollTo(0, csp - wd); }); }