Home › Forums › JavaScript › window scroll javascript error › Re: window scroll javascript error
May 13, 2013 at 12:51 pm
#134947
pixelgrid
Participant
the scroll event fires multiple times durring a scroll thats why the many errors
try
$window.scroll(function() {
var offset = $(“.navigation-timeline”).offset();
if ($window.scrollTop() > offset.top) {
$sidebar.stop().animate({
marginTop: $window.scrollTop() – offset.top + topPadding
});
} else {
$sidebar.stop().animate({
marginTop: 0
});
}……(rest of code)