Skip to content

Instantly share code, notes, and snippets.

@myungwoo-Y
Created August 16, 2020 09:47
Show Gist options
  • Save myungwoo-Y/eec8446f1ce948695ca820d340414401 to your computer and use it in GitHub Desktop.
Save myungwoo-Y/eec8446f1ce948695ca820d340414401 to your computer and use it in GitHub Desktop.
function throttle(
func: (event: React.TouchEvent<HTMLDivElement>) => void,
interval: number
) {
let lastCall = 0;
return function (arg: any) {
const now = Date.now();
if (lastCall + interval < now) {
lastCall = now;
return func(arg);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment