$(document).ready(function(){ bannerHeight(); $('#captions').flexslider({ animation: "slide", directionNav: false, controlNav: false }); $('#slider').flexslider({ animation: "slide", directionNav: false, sync: "#captions" }); $('#pd-slider').flexslider({ animation: "slide", directionNav: false }); $('#menu-slider').flexslider({ animation: "fade", slideshow: false, smoothHeight: true, controlNav: true, manualControls: ".controls li", directionNav: false }); nav(); if ($(window).width() > 1025) { $(document).on("scroll", parallax); $(document).on("scroll", flowerParallax); } else { $('.para').fadeIn(); } $(window).scroll(function() { var scroll = $(document).scrollTop(); var height = $("#banner").height(); //console.log(scroll); if (scroll >= height) { //console.log('a'); $("header").addClass("scrolled"); } else { $("header").removeClass("scrolled"); } }); $("#nav-toggle").click(function(){ $("header").toggleClass("open"); console.log("clicked"); }); }); function flowerParallax() { var wHeight = $(window).height(); var scrollPos = $(document).scrollTop(); $('.para').each(function () { if ($(this).offset().top > (scrollPos - $(this).height())) { var newOff = ($(this).offset().top - scrollPos); var speed = $(this).data("speed"); $(this).css('marginTop', (newOff / speed)); } }); $('.para').fadeIn(); } function parallax() { var wHeight = $(window).height(); var scrollPos = $(document).scrollTop(); $('.bgp').each(function () { if ($(this).offset().top > (scrollPos - $(this).height())) { var newOff = ($(this).offset().top - scrollPos); var speed = $(this).data("speed"); var newSpeed = (newOff / speed); $(this).css('background-position-y', (newSpeed)); } }); } $(function(){ $(window).resize(function(){ bannerHeight(); if ($(window).width() > 1025) { $(document).on("scroll", parallax); $(document).on("scroll", flowerParallax); } }).triggerHandler('resize'); }); function bannerHeight() { height = $(window).height(); scroll = $(document).scrollTop(); if(scroll > height) { $("header").addClass("scrolled"); } if ($(window).width() > 767) { $('#banner').height(height - 80); } else { $('#banner').removeAttr('style'); } } function nav() { $(document).ready(function () { $(document).on("scroll", onScroll); //smoothscroll $('#nav a[href^="#"]').on('click', function (e) { e.preventDefault(); $(document).off("scroll"); $('a').each(function () { $(this).removeClass('active'); }) $(this).addClass('active'); var target = this.hash, menu = target; $target = $(target); $('html, body').stop().animate({ 'scrollTop': $target.offset().top-80 }, 500, 'swing', function () { window.location.hash = target; $(document).on("scroll", onScroll); }); }); }); function onScroll(event){ var scrollPos = $(document).scrollTop(); $('#nav a').each(function () { var currLink = $(this); var refElement = $(currLink.attr("href")); if (refElement.position().top -85 <= scrollPos && refElement.position().top + refElement.height() > scrollPos) { $('ul#nav li a').removeClass("active"); currLink.addClass("active"); } else{ currLink.removeClass("active"); } }); } }