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 1/2] 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(); From 1b65c36743f527254c7784b66c642bc06893d90d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Souza?= Date: Wed, 1 Nov 2023 11:12:15 -0300 Subject: [PATCH 2/2] improve throttle function --- bigbluebutton-html5/imports/utils/throttle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigbluebutton-html5/imports/utils/throttle.js b/bigbluebutton-html5/imports/utils/throttle.js index 0eaead6847..0ec52ed054 100644 --- a/bigbluebutton-html5/imports/utils/throttle.js +++ b/bigbluebutton-html5/imports/utils/throttle.js @@ -22,7 +22,7 @@ export function throttle(func, delay, options = {}) { if (leadingExec && leading) { execute(); leadingExec = false; - const nextExecDelay = elapsed < delay ? delay - elapsed : 0; + const nextExecDelay = elapsed < delay ? delay - elapsed : delay; setTimeout(function () { leadingExec = true; }, nextExecDelay);