From: Evert Timberg Date: Sat, 10 Dec 2022 13:21:41 +0000 (-0500) Subject: Ensure that args are saved inside of the throttled helper (#10942) X-Git-Tag: v4.1.0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b491554995553de75bde8b95a27799924396a25a;p=thirdparty%2FChart.js.git 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 --- diff --git a/src/helpers/helpers.extras.ts b/src/helpers/helpers.extras.ts index 162103f85..754f60504 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); }); } };