Wednesday 22 May 2013
Issues | Jumping scroll fixed!
After two hours looking for a problem in my jquery I started searching the internet for new bits of code to add to my jquery. After trying a few I came across this fix:
Try changing this line:
$(scrollElem).animate({scrollTop: targetOffset}, 1000, function() {
location.hash = target;
});
To:
$(scrollElem).animate({scrollTop: targetOffset}, 1000, function() {
if(history.pushState) {
history.pushState(null, null, target);
}
else {
location.hash = target;
}
});
(Link: http://stackoverflow.com/questions/11007929/jquery-smooth-scroll-jumps-upon-first-load-i-with-fixed-side-bar)
It's completely sorted the jumping during a smooth scroll. I knew it was something to do with the .animate line but i couldn't understand what I was mean't to change it too. Below is a video of the fixed smooth scroll!
Labels:
Year 1
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment