aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils.mjs
diff options
context:
space:
mode:
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}