Created
April 20, 2016 22:23
-
-
Save rlivsey/4dd5ef5633d5e63768e08d6d33a0d969 to your computer and use it in GitHub Desktop.
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 watchPosition(obj, cb) { | |
var top = obj.scrollTop; | |
function checkPosition() { | |
requestAnimationFrame(function() { | |
var newTop = obj.scrollTop; | |
if (top !== newTop) { | |
cb({ oldValue: top, newValue: newTop }); | |
top = newTop; | |
} | |
checkPosition(); | |
}); | |
} | |
checkPosition(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment