REFactor: encapsulate scroll check logic into a function
This commit is contained in:
@@ -39,13 +39,17 @@ jQuery(function($) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
jQuery(function($) {
|
jQuery(function($) {
|
||||||
$(window).scroll(function() {
|
function checkScroll() {
|
||||||
if ($(this).scrollTop() >= 100) {
|
if ($(window).scrollTop() >= 100) {
|
||||||
$('header#masthead').addClass('fixed');
|
$('header#masthead').addClass('fixed');
|
||||||
} else {
|
} else {
|
||||||
$('header#masthead').removeClass('fixed');
|
$('header#masthead').removeClass('fixed');
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
$(window).scroll(checkScroll);
|
||||||
|
|
||||||
|
checkScroll();
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery(document).ready(function ($) {
|
jQuery(document).ready(function ($) {
|
||||||
|
|||||||
Reference in New Issue
Block a user