From: Anthony Talarico Date: Wed, 3 Aug 2016 20:43:25 +0000 (-0400) Subject: function doesn't work well, removing it and replacing with conditionals to check... X-Git-Tag: v1.0.0^2~21 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=67b82e72840755e56335f075864a30d50412fd47;p=WP-Themes%2Fpetoskey.git function doesn't work well, removing it and replacing with conditionals to check for window width during resize and scrolling --- diff --git a/js/app.js b/js/app.js index 795976f..44257a3 100644 --- a/js/app.js +++ b/js/app.js @@ -56,30 +56,32 @@ $(document).ready(function () { var sticky = $(".sticky"); var width = $(window).width(); var page_front = $(".page-front"); - function check_window_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"); - } - } + + + $(window).resize( function () { - check_window_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"); + } }); $(window).on("scroll", function () { var scrollTop = $(window).scrollTop(); if(scrollTop > 0){ $(sticky).addClass("fixed"); - check_window_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"); + } } - -// if(scrollTop == 0){ -// $(sticky).removeClass("fixed"); -// $(body).removeClass("f-topbar-fixed"); -// } + }); }); diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index cf725c9..d210608 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -47,30 +47,32 @@ $(document).ready(function () { var sticky = $(".sticky"); var width = $(window).width(); var page_front = $(".page-front"); - function check_window_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"); - } - } + + + $(window).resize( function () { - check_window_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"); + } }); $(window).on("scroll", function () { var scrollTop = $(window).scrollTop(); if(scrollTop > 0){ $(sticky).addClass("fixed"); - check_window_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"); + } } - -// if(scrollTop == 0){ -// $(sticky).removeClass("fixed"); -// $(body).removeClass("f-topbar-fixed"); -// } + }); });