Skip to content

Instantly share code, notes, and snippets.

@JustinWinthers
Last active September 23, 2015 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JustinWinthers/92b5ba7d0b19dfaebd2c to your computer and use it in GitHub Desktop.
Save JustinWinthers/92b5ba7d0b19dfaebd2c to your computer and use it in GitHub Desktop.
// smooth scrolling - just put any element with attribut data-smoothscroll='#idToScrollTo'
// requires jQuery
$(function () {
$('[data-smoothscroll]').click(
function (e) {
var target = $(this).attr('data-smoothscroll')
, targetElement = $(target);
if (targetElement.length) {
$('html,body').animate({
scrollTop: targetElement.offset().top
}, 750);
return false;
}
e.preventDefault();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment