-
-
Save cyaenorama/84a3f212e3aa060bbaf14a56d125812b to your computer and use it in GitHub Desktop.
Smooth Scroll
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
| var smooth = { | |
| Scroll: function(item, speed) { | |
| // when the item is clicked | |
| item.click(function() { | |
| // grab the html document and / or the body | |
| $("html, body").animate({ | |
| // grab the item clicked's href and get the distance between this element | |
| //and the element it is scrolling to | |
| scrollTop: $($(this).attr("href")).offset().top + "px" | |
| }, { | |
| duration: speed, | |
| easing: "swing" | |
| }); | |
| return false; | |
| }); | |
| } // end of scroll | |
| }; // end of smooth object literal | |
| // runs the function using these links or buttons | |
| smooth.Scroll($('#toContact'), 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment