Skip to content

Instantly share code, notes, and snippets.

@julienchazal
Last active August 29, 2015 14:00
Show Gist options
  • Save julienchazal/11357274 to your computer and use it in GitHub Desktop.
Save julienchazal/11357274 to your computer and use it in GitHub Desktop.
jQuery Smooth Scroll
$('a[href^="#"]').on("click", function(){
var the_id = $(this).attr("href");
$('html, body').animate({
scrollTop:$(the_id).offset().top
}, 'slow');
return false;
});
// si scroll dans un conteneur :
// scrollTop: $(elemId).parent().scrollTop() + $(elemId).offset().top - $(elemId).parent().offset().top
// http://www.qlambda.com/2012/10/smoothly-scroll-element-inside-div-with.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment