Skip to content

Instantly share code, notes, and snippets.

@marshallds
Forked from mrgenixus/minimum debounce.js
Last active October 14, 2021 23:08
Show Gist options
  • Save marshallds/11ba0bed227d003e325e8a040a69c717 to your computer and use it in GitHub Desktop.
Save marshallds/11ba0bed227d003e325e8a040a69c717 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