Created
March 11, 2015 18:35
-
-
Save vikt82/9acb5ecb079c063916dd to your computer and use it in GitHub Desktop.
определение процентов скрола
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 tmp = getScrollXY(); | |
| var fullHeight = $('body').height(); | |
| var perec = tmp[1] * 100/ fullHeight; | |
| console.log(perec + '%'); | |
| function getScrollXY() { | |
| var scrOfX = 0, scrOfY = 0; | |
| if( typeof( window.pageYOffset ) == 'number' ) { | |
| //Netscape compliant | |
| scrOfY = window.pageYOffset; | |
| scrOfX = window.pageXOffset; | |
| } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { | |
| //DOM compliant | |
| scrOfY = document.body.scrollTop; | |
| scrOfX = document.body.scrollLeft; | |
| } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { | |
| //IE6 standards compliant mode | |
| scrOfY = document.documentElement.scrollTop; | |
| scrOfX = document.documentElement.scrollLeft; | |
| } | |
| return [ scrOfX, scrOfY ]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment