Created
April 26, 2012 17:56
-
-
Save diegogangl/2501442 to your computer and use it in GitHub Desktop.
Simple function to smooth-scroll to the bottom of the page with a basic ease
This file contains 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
// ------------------------------------------------------------------------------- | |
// Metodo scrollear al final de la pagina | |
scrollToBottom : function() | |
{ | |
var acceleration = 1; | |
var totalOffset = 0; | |
var step = 1; | |
var scrollTimer = setInterval( function() | |
{ | |
window.scrollBy(0, (step + acceleration)); | |
offset = Math.max( window.pageYOffset, document.documentElement.scrollTop ); | |
acceleration++; | |
if( totalOffset >= offset ) | |
{ | |
clearInterval( scrollTimer ); | |
} | |
else | |
{ | |
totalOffset = offset; | |
} | |
}, 5); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment