Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- componentDidMount() {
- /**
- * infinite scroll listener
- */
- const listener = (e) => {
- const
- body = document.body,
- html = document.documentElement,
- skip = this.props.groupsAllReducer.getIn(['groupsQueryParams', 'skip']),
- limit = this.props.groupsAllReducer.getIn(['groupsQueryParams', 'limit']),
- groupsAllCount = this.props.groupsAllReducer.get('groupsAllCount'),
- isMoreGroupLoading = this.props.groupsAllReducer.get('isMoreGroupLoading'),
- scrollTopThis = document.documentElement.scrollTop || document.body.scrollTop;
- console.log('scrollTopThis: ', scrollTopThis, e.target.scrollTop);
- if ( scrollTopThis > this.scrollTopPrev && scrollTopThis + window.innerHeight > (body.clientHeight - 100) ) {
- if ( skip >= groupsAllCount) {
- window.removeEventListener('scroll', listener);
- }else if (!isMoreGroupLoading) {
- this.props.actions.moreGroup();
- }
- }
- this.scrollTopPrev = scrollTopThis;
- }
- this.infiniteScrollListener = listener;
- document.getElementById('toolbox-panel').addEventListener('scroll', this.infiniteScrollListener);
- }
- componentWillUnmount() {
- document.getElementById('toolbox-panel').removeEventListener('scroll', this.infiniteScrollListener);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement