My jQuery code shows a div
when the user scrolls down past 44px and disappears when scrolling up past 44px. I only want to show the div when scrolling down not up.
$(document).ready(function() {
$(window).scroll(function(e) {
// Variable declaration for search container
var $src = $('.main-div');
// Variable declaration for position fixed
var isPositionFixed = ($src.css('position') == 'fixed');
// Scroll if statement for position scroll - Scroll down
if ($(this).scrollTop() > 44 && !isPositionFixed) {
$src.css({
'position': 'fixed',
'top': '0'
});
$('.main-div').show();
}
// Scroll if statement for position scroll - Scroll up
if ($(this).scrollTop() < 44 && isPositionFixed) {
$src.css({
'position': 'static',
'top': '0'
});
$(".main-div").hide();
}
});
});