$(function () { $('a[href*=\\#]:not([href=\\#])').click(function () { if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']'); if ($target.length) { if($(this).parents('#gNavi').length){ if($(window).width() < 897){ $('body').removeClass('fixed').css({'top': 0}); window.scrollTo( 0 , scrollpos ); $('#gNavi').stop().slideUp(300); $('#gHeader .menu a').removeClass('on'); state = false; } setTimeout(function(){ var targetOffset = $target.offset().top - ($("#gHeader").outerHeight() - 2); $('html,body').animate({scrollTop: targetOffset}, 1000); },100) }else{ var targetOffset = $target.offset().top - ($("#gHeader").outerHeight() - 2); $('html,body').animate({scrollTop: targetOffset}, 1000); } return false; } } }); var pcflag,spflag; if($(window).width() > 896){ pcflag = 1; spflag = 0; }else{ pcflag = 0; spflag = 1; } $(window).resize(function(){ if($(window).width() < 897){ if(pcflag){ setTimeout(function(){window.location.reload()},100); pcflag = 0; spflag = 1; } }else{ if(spflag){ setTimeout(function(){window.location.reload()},100); pcflag = 1; spflag = 0; } } }); $(window).scroll(function () { var windowHeight = $(window).height(), topWindow = $(window).scrollTop(); $('.animation').each(function () { var targetPosition = $(this).offset().top; if (topWindow > targetPosition - windowHeight + 100) { $(this).addClass("fadeInUp"); } }); }).trigger('scroll'); if($(window).width() < 897){ var state = false; var scrollpos; $('#gHeader .menu a').on('click', function(){ if(state == false) { scrollpos = $(window).scrollTop(); $('body').addClass('fixed').css({'top': -scrollpos}); $('#gNavi').stop().slideDown(300); $('#gHeader .menu a').addClass('on'); state = true; } else { $('body').removeClass('fixed').css({'top': 0}); window.scrollTo( 0 , scrollpos ); $('#gNavi').stop().slideUp(300); $('#gHeader .menu a').removeClass('on'); state = false; } return false; }); } }); $(window).on('load', function () { var localLink = window.location + ''; if (localLink.indexOf("#") != -1 && localLink.slice(-1) != '#') { localLink = localLink.slice(localLink.indexOf("#") + 1); $('html,body').animate({ scrollTop: $('#' + localLink).offset().top - ($("#gHeader").outerHeight() - 2) }, 500); } });