From 5a505299fd501582208a12da1e5b5f94b37f49f9 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 5 Dec 2022 18:42:38 -0500 Subject: [PATCH 1/3] Ensure that args are saved inside of the throttled helper --- src/helpers/helpers.extras.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/helpers/helpers.extras.ts b/src/helpers/helpers.extras.ts index 162103f85f1..afa2b703c64 100644 --- a/src/helpers/helpers.extras.ts +++ b/src/helpers/helpers.extras.ts @@ -30,11 +30,13 @@ export function throttled>( let ticking = false; return function(...args: TArgs) { + // Save the args for use later + const argsToUse = Array.from(args) as TArgs; if (!ticking) { ticking = true; requestAnimFrame.call(window, () => { ticking = false; - fn.apply(thisArg, args); + fn.apply(thisArg, argsToUse); }); } }; From 521b7ef62dbfc4677c02bc032d92dce7683aca10 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Tue, 6 Dec 2022 17:23:22 -0500 Subject: [PATCH 2/3] Capture args in outer scope --- src/helpers/helpers.extras.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/helpers/helpers.extras.ts b/src/helpers/helpers.extras.ts index afa2b703c64..ce05c32cf8e 100644 --- a/src/helpers/helpers.extras.ts +++ b/src/helpers/helpers.extras.ts @@ -27,11 +27,12 @@ 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 - const argsToUse = Array.from(args) as TArgs; + argsToUse = Array.from(args) as TArgs; if (!ticking) { ticking = true; requestAnimFrame.call(window, () => { From b8333aa0ed0f301a9a56679fd9918281ec990714 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Fri, 9 Dec 2022 20:31:48 -0500 Subject: [PATCH 3/3] Simplify capture --- src/helpers/helpers.extras.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/helpers.extras.ts b/src/helpers/helpers.extras.ts index ce05c32cf8e..754f6050483 100644 --- a/src/helpers/helpers.extras.ts +++ b/src/helpers/helpers.extras.ts @@ -32,7 +32,7 @@ export function throttled>( return function(...args: TArgs) { // Save the args for use later - argsToUse = Array.from(args) as TArgs; + argsToUse = args; if (!ticking) { ticking = true; requestAnimFrame.call(window, () => {