Skip to content

Instantly share code, notes, and snippets.

@mrgenixus
Last active October 14, 2021 23:53
Show Gist options
  • Save mrgenixus/4122d4afba778fae1f623f6c8565d80d to your computer and use it in GitHub Desktop.
Save mrgenixus/4122d4afba778fae1f623f6c8565d80d to your computer and use it in GitHub Desktop.
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