10 May 2011 No Comments
jQuery animated page scroll
I found a nice snippet for animating the page scroll using the standard anchor link.
The original snippet can be found on oncemade.com. Below is an updated version that will automatically update all links that use the anchor for navigation.
$('a[href^="#"]').click(function(e) { var offset = 20; var duration = 500; var $dest = $(e.target.hash); if($dest.length != 0) { $("html:not(:animated),body:not(:animated)").animate({ scrollTop: $dest.offset().top-offset}, duration); } return false; });