From 67b82e72840755e56335f075864a30d50412fd47 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Wed, 3 Aug 2016 16:43:25 -0400 Subject: [PATCH] function doesn't work well, removing it and replacing with conditionals to check for window width during resize and scrolling --- js/app.js | 34 ++++++++++++++++++---------------- js/custom/pageSetup.js | 34 ++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 32 deletions(-) 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"); -// } + }); }); -- 2.17.1