Created
October 27, 2011 15:24
-
-
Save clawfire/1319869 to your computer and use it in GitHub Desktop.
scrollTo() without plugin
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
| <div id="top">Hello, I'm the top-gun!</div> | |
| <div id="bottom">Hello, I'm the bottom end :(</div> |
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 documentBody = (($.browser.chrome)||($.browser.safari)) ? document.body : document.documentElement; | |
| $('#top').click(function() { | |
| $(documentBody).animate({scrollTop: $('#bottom').offset().top}, 2000,'easeInOutCubic'); | |
| }); | |
| $('#bottom').click(function() { | |
| $(documentBody).animate({scrollTop: $('#top').offset().top}, 2000,'easeInOutCubic'); | |
| }); |
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
| #top { | |
| position: absolute; | |
| top: 0; | |
| } | |
| #bottom { | |
| position: absolute; | |
| top: 1200px; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment