From b491554995553de75bde8b95a27799924396a25a Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 10 Dec 2022 08:21:41 -0500 Subject: [PATCH] Ensure that args are saved inside of the throttled helper (#10942) * Ensure that args are saved inside of the throttled helper * Capture args in outer scope * Simplify capture --- src/helpers/helpers.extras.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/helpers/helpers.extras.ts b/src/helpers/helpers.extras.ts index 162103f85f1..754f6050483 100644 --- a/src/helpers/helpers.extras.ts +++ b/src/helpers/helpers.extras.ts @@ -27,14 +27,17 @@ export function throttled>( fn: (...args: TArgs) => void, thisArg: any, ) { + let argsToUse = [] as TArgs; let ticking = false; return function(...args: TArgs) { + // Save the args for use later + argsToUse = args; if (!ticking) { ticking = true; requestAnimFrame.call(window, () => { ticking = false; - fn.apply(thisArg, args); + fn.apply(thisArg, argsToUse); }); } };