Skip to content

Instantly share code, notes, and snippets.

@pbroschwitz
Created February 22, 2016 10:49
Show Gist options
  • Select an option

  • Save pbroschwitz/dbf8edea18530b40b9ff to your computer and use it in GitHub Desktop.

Select an option

Save pbroschwitz/dbf8edea18530b40b9ff to your computer and use it in GitHub Desktop.
onScroll(): () => void {
var last, timeout, threshold = 100;
return () => {
var now = Date.now();
if (last && now < last + threshold) {
window.clearTimeout(timeout);
timeout = window.setTimeout(function () {
last = now;
this.scrollFn();
}, threshold);
} else {
last = now;
this.scrollFn();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment