Created
August 16, 2020 09:47
-
-
Save myungwoo-Y/eec8446f1ce948695ca820d340414401 to your computer and use it in GitHub Desktop.
This file contains 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
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