jQuery(function($) { /* =============== SHOW / HIDE FORM SEARCH =============== */ $("header .search, #searchForm .close").click(function(){ $("#searchForm").toggleClass("open"); }); /* =============== SHOW / HIDE GOOGLE MAP =============== */ $("#map .sectionHeading").click(function(){ $("#map").toggleClass("showMap"); $(this).find(".text").toggle(); }); /* =============== Fancybox =============== */ $('.work-box').fancybox(); /* =============== Flexslider =============== */ $('.flexslider').flexslider({ animation: "fade", directionNav: false, }); /* =============== MAKE MAIN MENU STICKED ON TOP WHEN SCROLL =============== */ $(window).scroll(function () { if ($(this).scrollTop() == $('.main_slide').height() || $(this).scrollTop() > $('.main_slide').height()) { $('body').addClass("fixed-nav"); $('body').css('padding-top', $('#navbar').height() + 'px'); } else { $('body').removeClass("fixed-nav"); $('body').css('padding-top', 0); } }); /* =============== SMOOTH SCROOL EFFECT =============== */ $('#navbar ul li a').on('click',function (e) { e.preventDefault(); var target = this.hash, $target = $(target); $('html, body').stop().animate({ 'scrollTop': $target.offset().top }, 500, 'swing', function () { window.location.hash = target; }); }); /* =============== SHOW / HIDE GO TO TOP =============== */ /* Check to see if the window is top if not then display go top button */ $(window).scroll(function(){ if ($(this).scrollTop() > 200) { $('#scrollToTop').fadeIn(); } else { $('#scrollToTop').fadeOut(); } }); /* Click event to scroll to top */ $('#scrollToTop').click(function(){ $('html, body').animate({scrollTop : 0},800); return false; }); /* =============== ¸ð´Þ var body = document.getElementsByTagName('body')[0]; var bodyScrollTop = null; var locked = false; function lockScroll(){ if (!locked) { bodyScrollTop = (typeof window.pageYOffset !== 'undefined') ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop; body.classList.add('scroll-locked'); body.style.top = `-${bodyScrollTop}px`; locked = true; }; } function unlockScroll(){ if (locked) { body.classList.remove('scroll-locked'); body.style.top = null; window.scrollTo(0, bodyScrollTop); locked = false; } } =============== */ });