From 0688cba0b417ab9434c54db095c68668d0c2905b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Souza?= Date: Tue, 26 Sep 2023 13:50:51 -0300 Subject: [PATCH] fix leading:true, trailing:false throttle --- bigbluebutton-html5/imports/utils/throttle.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bigbluebutton-html5/imports/utils/throttle.js b/bigbluebutton-html5/imports/utils/throttle.js index 9d0e12ab84..0eaead6847 100644 --- a/bigbluebutton-html5/imports/utils/throttle.js +++ b/bigbluebutton-html5/imports/utils/throttle.js @@ -22,6 +22,10 @@ export function throttle(func, delay, options = {}) { if (leadingExec && leading) { execute(); leadingExec = false; + const nextExecDelay = elapsed < delay ? delay - elapsed : 0; + setTimeout(function () { + leadingExec = true; + }, nextExecDelay); } else if (!timeoutId && trailing) { timeoutId = setTimeout(function () { execute();