I have this snippet of Jquery for smooth scrolling to an anchor:
<li><a href="#home">Home</a></li>
to take you to...
<a name="home"></a>
.
var $root = $('html, body');
$('a').click(function() {
var href = $.attr(this, 'href');
$root.stop().animate({
scrollTop: $(href).offset().top
}, 500, function () {
window.location.hash = href;
});
return false;
});
it works great but is there a way to stop the animation if you scroll again, right now this has to finish the 500ms and goes jittery when try to scroll whilst it animates...
Any help would be great, thanks!