From f213e61812496567b786da4f473735a77fcd6f21 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Wed, 3 Aug 2016 16:50:52 -0400 Subject: [PATCH] fixed conditionals to get the width and scrolltop dynamically and apply padding to the top of the page front dive dynamically --- js/app.js | 28 +++++++++++++++++----------- js/custom/pageSetup.js | 28 +++++++++++++++++----------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/js/app.js b/js/app.js index 44257a3..879594f 100644 --- a/js/app.js +++ b/js/app.js @@ -54,33 +54,39 @@ $(document).ready(function () { var slideshow = $("#slideshow"); var body = $("body"); var sticky = $(".sticky"); - var width = $(window).width(); + var width; var page_front = $(".page-front"); + var scrollTop; $(window).resize( function () { + width = $(window).width(); + scrollTop = $(window).scrollTop(); + console.log("res" + scrollTop + " : " + width); if(width > 319 && width < 641 ){ $(page_front).css("padding-top", "200px"); } else if(width > 639 && width < 1025){ $(page_front).css("padding-top", "155px"); } else if(width > 1024){ - $(page_front).css("padding-top", "20px"); + $(page_front).css("padding-top", "60px"); } }); $(window).on("scroll", function () { - var scrollTop = $(window).scrollTop(); + width = $(window).width(); + scrollTop = $(window).scrollTop(); + console.log("scr" + scrollTop + " : " + width); if(scrollTop > 0){ $(sticky).addClass("fixed"); - if(width > 319 && width < 641 ){ - $(page_front).css("padding-top", "200px"); - } else if(width > 639 && width < 1025){ - $(page_front).css("padding-top", "155px"); - } else if(width > 1024){ - $(page_front).css("padding-top", "20px"); - } - } + } + if(width > 319 && width < 641 ){ + $(page_front).css("padding-top", "200px"); + } else if(width > 639 && width < 1025){ + $(page_front).css("padding-top", "155px"); + } else if(width > 1024){ + $(page_front).css("padding-top", "60px"); + } }); diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index d210608..84b3efb 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -45,33 +45,39 @@ $(document).ready(function () { var slideshow = $("#slideshow"); var body = $("body"); var sticky = $(".sticky"); - var width = $(window).width(); + var width; var page_front = $(".page-front"); + var scrollTop; $(window).resize( function () { + width = $(window).width(); + scrollTop = $(window).scrollTop(); + console.log("res" + scrollTop + " : " + width); if(width > 319 && width < 641 ){ $(page_front).css("padding-top", "200px"); } else if(width > 639 && width < 1025){ $(page_front).css("padding-top", "155px"); } else if(width > 1024){ - $(page_front).css("padding-top", "20px"); + $(page_front).css("padding-top", "60px"); } }); $(window).on("scroll", function () { - var scrollTop = $(window).scrollTop(); + width = $(window).width(); + scrollTop = $(window).scrollTop(); + console.log("scr" + scrollTop + " : " + width); if(scrollTop > 0){ $(sticky).addClass("fixed"); - if(width > 319 && width < 641 ){ - $(page_front).css("padding-top", "200px"); - } else if(width > 639 && width < 1025){ - $(page_front).css("padding-top", "155px"); - } else if(width > 1024){ - $(page_front).css("padding-top", "20px"); - } - } + } + if(width > 319 && width < 641 ){ + $(page_front).css("padding-top", "200px"); + } else if(width > 639 && width < 1025){ + $(page_front).css("padding-top", "155px"); + } else if(width > 1024){ + $(page_front).css("padding-top", "60px"); + } }); -- 2.17.1