Last active
March 18, 2016 13:31
-
-
Save iamravenous/9d1c72f8c2e4aa2af6e1 to your computer and use it in GitHub Desktop.
Easy and reusable script for smoothing scroll to top
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 scroll to top | |
* Easy and reusable script for smoothing scroll to top | |
* Author: Franco Moya - @iamravenous | |
* Usage: Add data-scroll="top" to the link or element you want to scroll to top | |
*/ | |
$('[data-scroll="top"]').click(function(e){ | |
e.preventDefault(); | |
$('body,html').animate({ | |
scrollTop: 0 | |
}, 1500, 'swing'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment