Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

ref(toolbar): replace custom debounce with lodash throttle

Leonard Kimec7c10c99b8a
diff --git a/modules/UI/UI.js b/modules/UI/UI.js
index 4f98236878..f319868592 100644
--- a/modules/UI/UI.js
+++ b/modules/UI/UI.js
@@ -4,6 +4,8 @@ const logger = require("jitsi-meet-logger").getLogger(__filename);
var UI = {};
+import _ from 'lodash';
+
import Chat from "./side_pannels/chat/Chat";
import SidePanels from "./side_pannels/SidePanels";
import Avatar from "./avatar/Avatar";
@@ -20,7 +22,6 @@ import Filmstrip from "./videolayout/Filmstrip";
import SettingsMenu from "./side_pannels/settings/SettingsMenu";
import Profile from "./side_pannels/profile/Profile";
import Settings from "./../settings/Settings";
-import { debounce } from "../util/helpers";
import { updateDeviceList } from '../../react/features/base/devices';
import {
@@ -278,13 +279,13 @@ UI.start = function () {
sharedVideoManager = new SharedVideoManager(eventEmitter);
if (!interfaceConfig.filmStripOnly) {
- let debouncedShowToolbar
- = debounce(
+ let throttledShowToolbar
+ = _.throttle(
() => UI.showToolbar(),
100,
{ leading: true, trailing: false });
- $("#videoconference_page").mousemove(debouncedShowToolbar);
+ $("#videoconference_page").mousemove(throttledShowToolbar);
// Initialise the recording module.
if (config.enableRecording) {
diff --git a/modules/util/helpers.js b/modules/util/helpers.js
index 39d173d49d..c429e74f5b 100644
--- a/modules/util/helpers.js
+++ b/modules/util/helpers.js
@@ -16,36 +16,6 @@ export function createDeferred() {
return deferred;
}
-/**
- * Creates a debounced function that delays invoking func until after wait
- * milliseconds have elapsed since the last time the debounced function was
- * invoked.
- *
- * @param fn
- * @param wait
- * @param options
- * @returns {function(...[*])}
- */
-export function debounce(fn, wait = 0, options = {}) {
- const leading = options.leading || false;
- const trailing
- = (typeof options.trailing === 'undefined') || options.trailing;
- let called = false;
-
- return (...args) => {
- if (!called) {
- leading && fn(...args);
-
- setTimeout(() => {
- called = false;
- trailing && fn(...args);
- }, wait);
-
- called = true;
- }
- };
-}
-
/**
* Returns the namespace for all global variables, functions, etc that we need.
*