Skip to content

Instantly share code, notes, and snippets.

@jovey-zheng
Last active April 13, 2016 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jovey-zheng/22c1a0260a99baee433d0fcbbc3c682d to your computer and use it in GitHub Desktop.
Save jovey-zheng/22c1a0260a99baee433d0fcbbc3c682d to your computer and use it in GitHub Desktop.
when user scroll some position then auto loading data ...
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