Skip to content

Instantly share code, notes, and snippets.

@logzh
Created April 7, 2016 05:15
Show Gist options
  • Save logzh/c86574f7e5087ee6f8be8e1c659fb1b7 to your computer and use it in GitHub Desktop.
Save logzh/c86574f7e5087ee6f8be8e1c659fb1b7 to your computer and use it in GitHub Desktop.
react 底部向上滑动获取更多数据
//console.log(window.scrollY) // 文档在垂直方向已滚动的像素值。
//console.log(window.innerHeight) // 浏览器窗口的视口(viewport)高度(以像素为单位)
//console.log(document.body.scrollHeight)
//console.log(window.scrollY)
_.debounce(function() {
var props = this.props;
if (typeof window !== 'undefined') {
if (!props.isFetchingList && props.hasMorePosts && (document.body.scrollHeight - window.innerHeight - window.scrollY) <= 100) {
props.actions.fetchThreadReply(props.id, props.posts.length);
}
}
}, 500),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment