Last active
April 13, 2016 08:26
-
-
Save jovey-zheng/22c1a0260a99baee433d0fcbbc3c682d to your computer and use it in GitHub Desktop.
when user scroll some position then auto loading data ...
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
handleAppend() { | |
const top = window.pageYOffset || | |
document.documentElement.scrollTop || | |
document.body.scrollTop; | |
if (!isEmpty(data) | |
&& (top + window.innerHeight) / document.body.scrollHeight > 0.9 | |
&& !isloading // false | |
) { | |
//do something ... | |
} | |
} | |
window.addEventListener('scroll', handleAppend, false); //listen the `scroll` event. | |
window.removeEventListener('scroll', handleAppend, false); //remove the `scroll` event. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment