aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils.mjs
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-09-24 17:28:08 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-09-24 18:44:04 +0800
commitbd1c1973e31354d9effccae5f1bf7f4f16e13bdd (patch)
tree8893bd05e79df67d63ee061869318263d9d323cc /src/utils.mjs
parent14803d63c82d95ad96e31222c3d853e1fe4931bc (diff)
refactor: move utils about dumbymap into module
Diffstat (limited to 'src/utils.mjs')
-rw-r--r--src/utils.mjs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/utils.mjs b/src/utils.mjs
index e7d306e..46632ba 100644
--- a/src/utils.mjs
+++ b/src/utils.mjs
@@ -74,14 +74,15 @@ export const animateRectTransition = (element, rect, options = {}) => {
74export function throttle(func, delay) { 74export function throttle(func, delay) {
75 let timerFlag = null; 75 let timerFlag = null;
76 76
77 return (...args) => { 77 return function(...args) {
78 const context = this
78 if (timerFlag !== null) return null 79 if (timerFlag !== null) return null
79 80
80 timerFlag = setTimeout( 81 timerFlag = setTimeout(
81 () => timerFlag = null, 82 () => timerFlag = null,
82 typeof delay === 'function' ? delay() : delay 83 typeof delay === 'function' ? delay.call(context) : delay
83 ); 84 );
84 85
85 return func(...args); 86 return func.call(context, ...args);
86 }; 87 };
87} 88}