Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. componentDidMount() {
  2. /**
  3. * infinite scroll listener
  4. */
  5. const listener = (e) => {
  6. const
  7. body = document.body,
  8. html = document.documentElement,
  9. skip = this.props.groupsAllReducer.getIn(['groupsQueryParams', 'skip']),
  10. limit = this.props.groupsAllReducer.getIn(['groupsQueryParams', 'limit']),
  11. groupsAllCount = this.props.groupsAllReducer.get('groupsAllCount'),
  12. isMoreGroupLoading = this.props.groupsAllReducer.get('isMoreGroupLoading'),
  13. scrollTopThis = document.documentElement.scrollTop || document.body.scrollTop;
  14.  
  15. console.log('scrollTopThis: ', scrollTopThis, e.target.scrollTop);
  16. if ( scrollTopThis > this.scrollTopPrev && scrollTopThis + window.innerHeight > (body.clientHeight - 100) ) {
  17. if ( skip >= groupsAllCount) {
  18. window.removeEventListener('scroll', listener);
  19. }else if (!isMoreGroupLoading) {
  20. this.props.actions.moreGroup();
  21. }
  22. }
  23. this.scrollTopPrev = scrollTopThis;
  24. }
  25. this.infiniteScrollListener = listener;
  26. document.getElementById('toolbox-panel').addEventListener('scroll', this.infiniteScrollListener);
  27. }
  28.  
  29. componentWillUnmount() {
  30. document.getElementById('toolbox-panel').removeEventListener('scroll', this.infiniteScrollListener);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement