浏览代码

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

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

16
     return deferred;
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
  * Returns the namespace for all global variables, functions, etc that we need.
20
  * Returns the namespace for all global variables, functions, etc that we need.
51
  *
21
  *

正在加载...
取消
保存