Last active
December 28, 2015 09:49
-
-
Save stekhn/7481563 to your computer and use it in GitHub Desktop.
Function that returns the current scroll position. Useful for "snowfallesk" and parallax scrolling projects.
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
function getScrollY() { | |
var currentY = 0; | |
if (typeof( window.pageYOffset ) == 'number') { | |
currentY = window.pageYOffset; | |
} else if (document.body && ( document.body.scrollLeft || document.body.scrollTop )) { | |
currentY = document.body.scrollTop; | |
} else if (document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop )) { | |
currentY = document.documentElement.scrollTop; | |
} | |
return currentY; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment