Skip to content

Commit

Permalink
Ensure that args are saved inside of the throttled helper
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Dec 5, 2022
1 parent 8283ad5 commit 5a50529
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/helpers/helpers.extras.ts
Expand Up @@ -30,11 +30,13 @@ export function throttled<TArgs extends Array<any>>(
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);
});
}
};
Expand Down

0 comments on commit 5a50529

Please sign in to comment.