Created
June 26, 2012 21:12
-
-
Save ericwwsun/2999079 to your computer and use it in GitHub Desktop.
Javascript: On window scrolling, do something based on % of document height
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
// On window scrolling | |
$j(window).scroll(function(){ | |
// update the ruler's color based on scroll position | |
var docHeight = $j(document).height(); | |
var scrollTop = $j(window).scrollTop(); | |
var currPos = scrollTop/docHeight*100; | |
//console.log( currPos + "%"); | |
if( (currPos > 13 && currPos < 21) || currPos > 64 ) { | |
//do something in between 13% and 21% and grater than 64% | |
} else { | |
//undo things | |
} | |
}); // end of scrolling |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment