I have some Jquery code that makes a div sticky on scroll down and scroll up. It seems to be fine on desktop, problem is when I test on iphone and scroll up and get to the top of the page it still applies the .sticky
class, which is should not. Is this an issue with the device, known issue? This is my code:
CSS
.sticky {
top: 44px!important;
position:fixed;
}
.sticky2 {
top: 88px!important;
position:fixed;
}
JQUERY
var lastScrollTop = 0;
$(window).scroll(function(event){
var $src = $('.fixed');
var st = $(this).scrollTop();
if (st > lastScrollTop){
$src.last().addClass("sticky");
$src.last().removeClass("sticky2");
} else {
$src.last().removeClass("sticky");
$src.last().addClass("sticky2");
}
lastScrollTop = st;
});