瀏覽代碼

Merge pull request #1916 from virtuacoplenny/lenny/no-custom-debounce

ref(toolbar): replace custom debounce with lodash throttle
j8
Saúl Ibarra Corretgé 7 年之前
父節點
當前提交
e04129bf4d
共有 2 個文件被更改,包括 5 次插入34 次删除
  1. 5
    4
      modules/UI/UI.js
  2. 0
    30
      modules/util/helpers.js

+ 5
- 4
modules/UI/UI.js 查看文件

@@ -4,6 +4,8 @@ const logger = require("jitsi-meet-logger").getLogger(__filename);
4 4
 
5 5
 var UI = {};
6 6
 
7
+import _ from 'lodash';
8
+
7 9
 import Chat from "./side_pannels/chat/Chat";
8 10
 import SidePanels from "./side_pannels/SidePanels";
9 11
 import Avatar from "./avatar/Avatar";
@@ -20,7 +22,6 @@ import Filmstrip from "./videolayout/Filmstrip";
20 22
 import SettingsMenu from "./side_pannels/settings/SettingsMenu";
21 23
 import Profile from "./side_pannels/profile/Profile";
22 24
 import Settings from "./../settings/Settings";
23
-import { debounce } from "../util/helpers";
24 25
 
25 26
 import { updateDeviceList } from '../../react/features/base/devices';
26 27
 import {
@@ -278,13 +279,13 @@ UI.start = function () {
278 279
 
279 280
     sharedVideoManager = new SharedVideoManager(eventEmitter);
280 281
     if (!interfaceConfig.filmStripOnly) {
281
-        let debouncedShowToolbar
282
-            = debounce(
282
+        let throttledShowToolbar
283
+            = _.throttle(
283 284
                     () => UI.showToolbar(),
284 285
                     100,
285 286
                     { leading: true, trailing: false });
286 287
 
287
-        $("#videoconference_page").mousemove(debouncedShowToolbar);
288
+        $("#videoconference_page").mousemove(throttledShowToolbar);
288 289
 
289 290
         // Initialise the recording module.
290 291
         if (config.enableRecording) {

+ 0
- 30
modules/util/helpers.js 查看文件

@@ -16,36 +16,6 @@ export function createDeferred() {
16 16
     return deferred;
17 17
 }
18 18
 
19
-/**
20
- * Creates a debounced function that delays invoking func until after wait
21
- * milliseconds have elapsed since the last time the debounced function was
22
- * invoked.
23
- *
24
- * @param fn
25
- * @param wait
26
- * @param options
27
- * @returns {function(...[*])}
28
- */
29
-export function debounce(fn, wait = 0, options = {}) {
30
-    const leading = options.leading || false;
31
-    const trailing
32
-        = (typeof options.trailing === 'undefined') || options.trailing;
33
-    let called = false;
34
-
35
-    return (...args) => {
36
-        if (!called) {
37
-            leading && fn(...args);
38
-
39
-            setTimeout(() => {
40
-                called = false;
41
-                trailing && fn(...args);
42
-            }, wait);
43
-
44
-            called = true;
45
-        }
46
-    };
47
-}
48
-
49 19
 /**
50 20
  * Returns the namespace for all global variables, functions, etc that we need.
51 21
  *

Loading…
取消
儲存