/*----------------------------------------------------------------------------------- /* /* Init JS /* -----------------------------------------------------------------------------------*/ jQuery(document).ready(function() { $WIN = $(window); /* Preloader * -------------------------------------------------- */ var Preloader = function() { $WIN.on('load', function() { // will first fade out the loading animation $("#loader").fadeOut("slow", function(){ // will fade out the whole DIV that covers the website. $("#preloader").delay(300).fadeOut("slow"); }); }); }; /*----------------------------------------------------*/ /* Flexslider /*----------------------------------------------------*/ $('#intro-slider').flexslider({ animation: 'fade', controlNav: true, directionNav: true, touch: true, }); $('#about-slider').flexslider({ animation: 'fade', controlNav: true, directionNav: false, smoothHeight: true, touch: true, }); /* superfish * -------------------------------------------------- */ var SuperFish = function() { $('ul.sf-menu').superfish({ animation: { height:'show' }, // slide-down effect without fade-in animationOut: { height:'hide'}, // slide-up effect without fade-in cssArrows: false, // disable css arrows delay: 600, // .6 second delay on mouseout speed: 'fast', }); }; /* Smooth Scrolling * ------------------------------------------------------ */ var SmoothScroll = function() { $('.smoothscroll').on('click', function (e) { var target = this.hash, $target = $(target); e.preventDefault(); e.stopPropagation(); $('html, body').stop().animate({ 'scrollTop': $target.offset().top }, cfg.scrollDuration, 'swing').promise().done(function () { window.location.hash = target; }); }); }; /* Back to Top * ------------------------------------------------------ */ // declare variable var scrollTop = $(".scrollTop"); $(window).scroll(function() { // declare variable var topPos = $(this).scrollTop(); // if user scrolls down - show scroll to top button if (topPos > 100) { $(scrollTop).css("opacity", "1"); } else { $(scrollTop).css("opacity", "0"); } }); // scroll END //Click event to scroll to top $(scrollTop).click(function() { $('html, body').animate({ scrollTop: 0 }, 300); return false; }); // click() scroll top EMD /* Initialize * ------------------------------------------------------ */ (function ssInit() { Preloader(); SuperFish(); SmoothScroll(); })(); });