Last active
October 14, 2021 23:53
-
-
Save mrgenixus/4122d4afba778fae1f623f6c8565d80d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Component extends React.Component { | |
onScroll(event) { | |
this.scrollPosition = getScrollPosition(event); | |
if (this.scrolling) return; | |
this.scrolling = true; | |
const processLongOperation = (beginPosition) => { | |
longOperation(beginPosition, (completionState) => { | |
this.setState(completionState, () => { | |
//rendered | |
if (this.scrollPosition === beginPosition) { | |
this.scrolling = false; | |
} else { | |
_.defer(processLongOperation, this.scrollPosition); | |
} | |
}); | |
}); | |
}; | |
processLongOperation(this.scrollPostion); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment