Last active
September 23, 2015 01:17
-
-
Save JustinWinthers/92b5ba7d0b19dfaebd2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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