$(function(){ var wsize = window.innerWidth ? window.innerWidth: $(window).width(); $('#main, #header, #footer,#mv').animate({opacity:1},500); $('body').css({overflow:'auto'}); $('.spinner').animate({opacity:0},500); setTimeout(function(){ $('.spinner').hide(); },500); if(wsize > 767){ $("#Pagetop").hide(); $(window).on('scroll',function () { if ($(this).scrollTop() > 150) { $('#Pagetop').fadeIn(); } else { $('#Pagetop').fadeOut(); } }); } $('#footer-nav').prepend( $('.main-nav ul').clone() ); $('#footer-nav li').removeClass('col-md-auto col-6').addClass('col-auto'); $('#Pagetop').click(function () { $('body,html').animate({ scrollTop: 0 }, 800); return false; }); $('a').click(function() { var href= $(this).attr('href'); if( href.startsWith('#') ){ window.history.pushState('',''); var target = $(href == '#' || href == '' ? 'html' : href); var position = target.offset().top; $('body,html').animate({scrollTop:position}, 700); return false; } }); if( wsize < 991 || window.devicePixelRatio == 2 ) { $('.main-nav > ul > li > a').click(function(e){ if( $(this).next('ul').html() ){ e.preventDefault(); } $( this ).next('ul').stop().slideToggle( 250 ); }); }else{ $('.main-nav > ul > li').on('mouseover mouseout',function(){ $( this ).children('ul').stop().slideToggle( 250 ); }); } $('.navbar-toggle').on('click',function(){ if ( $('#header .main-nav').is(':hidden') ) { $(this).addClass('is-open'); $('#header .main-nav').show(); $('#header .main-nav').animate({ bottom: '13.9vw', opacity:1},400); }else{ $(this).removeClass('is-open'); $('#header .main-nav').animate({ bottom:'-14vw', opacity:0 },400); setTimeout(function(){ $('#header .main-nav').hide();},400); } }); var ua = navigator.userAgent; if (ua.indexOf('iPhone') > 0) { var touch_y = 0; var slide_y = 0; var minus_y = false; $("body").bind("touchstart", TouchStart); $("body").bind("touchmove" , TouchMove); $("body").bind("touchend" , TouchLeave); function TouchStart( event ) { var pos = Position(event); touch_y = pos.y; } function TouchMove( event ) { var pos = Position(event); var cal_y = pos.y - touch_y; if(cal_y < 0){ minus_y = true; }else{ minus_y = false; } slide_y = Math.sqrt(Math.pow(cal_y,2)); } function TouchLeave( event ) { if(slide_y > 20){ if(minus_y == true){ $("#inquiry-area").animate({bottom:-$("#inquiry-area").height()},200); }else{ $("#inquiry-area").animate({bottom:0},200); } } } function Position(e){ var y = e.originalEvent.touches[0].pageY; y = Math.floor(y); var pos = {'y':y}; return pos; } } var navurl = $(location).attr('href'); $('.main-nav li a').each(function(){ var navlink = $(this).attr('href'); if(navlink == navurl){ $(this).addClass('active'); } }); });