Created
October 12, 2011 12:20
-
-
Save getflourish/1281079 to your computer and use it in GitHub Desktop.
Scroll to an anchor with transition
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
| <script type="text/javascript"> | |
| $(document).ready(function() { | |
| $('.scrollPage').click(function() { | |
| var elementClicked = $(this).attr("href"); | |
| var destination = $(elementClicked).offset().top; | |
| $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination+1}, 500, function() { window.location.href = elementClicked;} ); | |
| return false; | |
| }); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment