feat: throttle helper

This commit is contained in:
karishmas6
2024-06-14 22:28:29 +05:30
parent c96ad7bc4c
commit cdc96e5ef1

View File

@@ -0,0 +1,21 @@
import {
ONE_PERCENT_OF_VIEWPORT_H,
ONE_PERCENT_OF_VIEWPORT_W,
VIEWPORT_W,
VIEWPORT_H,
} from "../constants/const";
import { Coordinates } from '../components/atoms/canvas';
export const throttle = (callback: any, limit: number) => {
let wait = false;
return (...args: any[]) => {
if (!wait) {
callback(...args);
wait = true;
setTimeout(function () {
wait = false;
}, limit);
}
}
}