REFactor: encapsulate scroll check logic into a function

This commit is contained in:
Roman Pyrih
2025-04-17 12:38:19 +02:00
parent 87667291e5
commit f53abaf13b

View File

@@ -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 ($) {