diff --git a/wp-content/themes/restly-child/assets/js/custom.js b/wp-content/themes/restly-child/assets/js/custom.js index 0fdd1acc..a30cfba5 100644 --- a/wp-content/themes/restly-child/assets/js/custom.js +++ b/wp-content/themes/restly-child/assets/js/custom.js @@ -39,13 +39,17 @@ jQuery(function($) { }) jQuery(function($) { - $(window).scroll(function() { - if ($(this).scrollTop() >= 100) { + function checkScroll() { + if ($(window).scrollTop() >= 100) { $('header#masthead').addClass('fixed'); } else { $('header#masthead').removeClass('fixed'); } - }); + } + + $(window).scroll(checkScroll); + + checkScroll(); }); jQuery(document).ready(function ($) {