浏览代码

Merge pull request #1059 from BeatC/toolbar-animation

Change main toolbar animation; optimize mousemove handler
master
hristoterezov 8 年前
父节点
当前提交
0bb772d242
共有 5 个文件被更改,包括 77 次插入29 次删除
  1. 16
    17
      css/_animations.scss
  2. 10
    3
      css/_toolbars.scss
  3. 5
    3
      modules/UI/UI.js
  4. 10
    6
      modules/UI/toolbars/Toolbar.js
  5. 36
    0
      modules/util/helpers.js

+ 16
- 17
css/_animations.scss 查看文件

3
 **/
3
 **/
4
 
4
 
5
 /**
5
 /**
6
- * START of slide in animation for extended toolbar.
6
+ *   Slide in animation for extended toolbar.
7
  */
7
  */
8
 @include keyframes(slideInX) {
8
 @include keyframes(slideInX) {
9
     0% { transform: translateX(-100%); }
9
     0% { transform: translateX(-100%); }
26
 }
26
 }
27
 
27
 
28
 /**
28
 /**
29
- * END of slide out animation for extended toolbar.
29
+ *   Slide in / out animation for main toolbar.
30
  */
30
  */
31
 
31
 
32
-/**
33
- * START of slide in / out animation for main toolbar.
34
- */
35
 @include keyframes(slideInY) {
32
 @include keyframes(slideInY) {
36
     100% { transform: translateY(0%); }
33
     100% { transform: translateY(0%); }
37
 }
34
 }
42
 }
39
 }
43
 
40
 
44
 /**
41
 /**
45
- * END of slide in / out animation for main toolbar.
46
- */
47
-
48
-/**
49
- * START of slide in animation for extended toolbar (inner) panel.
42
+ *   Slide in animation for extended toolbar (inner) panel.
50
  */
43
  */
51
 
44
 
52
 // FIX: Can't use percentage because of breaking animation when width is changed
45
 // FIX: Can't use percentage because of breaking animation when width is changed
62
 }
55
 }
63
 
56
 
64
 /**
57
 /**
65
- * END of slide in animation for extended toolbar (inner) panel.
66
- */
67
-
68
-/**
69
-* START of slide in animation for extended toolbar container
58
+*   Slide in animation for extended toolbar container
70
 **/
59
 **/
71
 
60
 
72
 @include keyframes(slideOutExtContainer) {
61
 @include keyframes(slideOutExtContainer) {
80
 }
69
 }
81
 
70
 
82
 /**
71
 /**
83
-* END of slide in animation for extended toolbar container
84
-**/
72
+*   Fade in / out animations
73
+**/
74
+
75
+@include keyframes(fadeIn) {
76
+    from { opacity: 0; }
77
+    to { opacity: 1; }
78
+}
79
+
80
+@include keyframes(fadeOut) {
81
+    from { opacity: 1; }
82
+    to { opacity: 0; }
83
+}

+ 10
- 3
css/_toolbars.scss 查看文件

16
     z-index: $toolbarZ;
16
     z-index: $toolbarZ;
17
     pointer-events: none;
17
     pointer-events: none;
18
     min-height: 100px;
18
     min-height: 100px;
19
-    transform: translateY(-100%);
20
-    -webkit-transform: translateY(-100%);
19
+    opacity: 0;
21
 }
20
 }
22
 
21
 
23
 #subject {
22
 #subject {
273
 }
272
 }
274
 
273
 
275
 /**
274
 /**
276
- * END of slide in animation for extended toolbar panel.
275
+ * START of fade in animation for main toolbar
277
  */
276
  */
277
+
278
+.fadeIn {
279
+    @include animation('fadeIn .3s forwards');
280
+}
281
+
282
+.fadeOut {
283
+    @include animation('fadeOut .3s forwards');
284
+}

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

23
 import RingOverlay from "./ring_overlay/RingOverlay";
23
 import RingOverlay from "./ring_overlay/RingOverlay";
24
 import RandomUtil from "../util/RandomUtil";
24
 import RandomUtil from "../util/RandomUtil";
25
 import UIErrors from './UIErrors';
25
 import UIErrors from './UIErrors';
26
+import { debounce } from "../util/helpers";
26
 
27
 
27
 var EventEmitter = require("events");
28
 var EventEmitter = require("events");
28
 UI.messageHandler = require("./util/MessageHandler");
29
 UI.messageHandler = require("./util/MessageHandler");
433
     bindEvents();
434
     bindEvents();
434
     sharedVideoManager = new SharedVideoManager(eventEmitter);
435
     sharedVideoManager = new SharedVideoManager(eventEmitter);
435
     if (!interfaceConfig.filmStripOnly) {
436
     if (!interfaceConfig.filmStripOnly) {
436
-        $("#videoconference_page").mousemove(function () {
437
-            return UI.showToolbar();
438
-        });
437
+        let debouncedShowToolbar = debounce(() => {
438
+            UI.showToolbar();
439
+        }, 100, { leading: true, trailing: false });
440
+        $("#videoconference_page").mousemove(debouncedShowToolbar);
439
         setupToolbars();
441
         setupToolbars();
440
         setupChat();
442
         setupChat();
441
 
443
 

+ 10
- 6
modules/UI/toolbars/Toolbar.js 查看文件

608
      * @return <tt>true</tt> if currently visible, <tt>false</tt> - otherwise
608
      * @return <tt>true</tt> if currently visible, <tt>false</tt> - otherwise
609
      */
609
      */
610
     isVisible() {
610
     isVisible() {
611
-        return this.toolbarSelector.hasClass("slideInY");
611
+        return this.toolbarSelector.hasClass("fadeIn");
612
     },
612
     },
613
 
613
 
614
     /**
614
     /**
616
      * parameter.
616
      * parameter.
617
      */
617
      */
618
     hide() {
618
     hide() {
619
-        this.toolbarSelector.toggleClass("slideInY").toggleClass("slideOutY");
619
+        this.toolbarSelector
620
+            .removeClass("fadeIn")
621
+            .addClass("fadeOut");
620
 
622
 
621
         let slideInAnimation = (SideContainerToggler.isVisible)
623
         let slideInAnimation = (SideContainerToggler.isVisible)
622
                                     ? "slideInExtX"
624
                                     ? "slideInExtX"
634
      * parameter.
636
      * parameter.
635
      */
637
      */
636
     show() {
638
     show() {
637
-        if (this.toolbarSelector.hasClass("slideOutY"))
638
-            this.toolbarSelector.toggleClass("slideOutY");
639
+        if (this.toolbarSelector.hasClass("fadeOut")) {
640
+            this.toolbarSelector.removeClass("fadeOut");
641
+        }
639
 
642
 
640
         let slideInAnimation = (SideContainerToggler.isVisible)
643
         let slideInAnimation = (SideContainerToggler.isVisible)
641
                                 ? "slideInExtX"
644
                                 ? "slideInExtX"
644
                                 ? "slideOutExtX"
647
                                 ? "slideOutExtX"
645
                                 : "slideOutX";
648
                                 : "slideOutX";
646
 
649
 
647
-        if (this.extendedToolbarSelector.hasClass(slideOutAnimation))
650
+        if (this.extendedToolbarSelector.hasClass(slideOutAnimation)) {
648
             this.extendedToolbarSelector.toggleClass(slideOutAnimation);
651
             this.extendedToolbarSelector.toggleClass(slideOutAnimation);
652
+        }
649
 
653
 
650
-        this.toolbarSelector.toggleClass("slideInY");
654
+        this.toolbarSelector.addClass("fadeIn");
651
         this.extendedToolbarSelector.toggleClass(slideInAnimation);
655
         this.extendedToolbarSelector.toggleClass(slideInAnimation);
652
     },
656
     },
653
 
657
 

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

40
         window.onerror(msg, null, null,
40
         window.onerror(msg, null, null,
41
             null, e);
41
             null, e);
42
 }
42
 }
43
+
44
+/**
45
+ * Creates a debounced function that delays invoking func until after wait
46
+ * milliseconds have elapsed since the last time the debounced
47
+ * function was invoked
48
+ * @param fn
49
+ * @param wait
50
+ * @param options
51
+ * @returns {function(...[*])}
52
+ */
53
+export function debounce(fn, wait = 0, options = {}) {
54
+    let leading = options.leading || false;
55
+    let trailing = true;
56
+    let isCalled = false;
57
+
58
+    if (typeof options.trailing !== 'undefined') {
59
+        trailing = options.trailing;
60
+    }
61
+
62
+    return (...args) => {
63
+        if(!isCalled) {
64
+            if (leading) {
65
+                fn(...args);
66
+            }
67
+
68
+            setTimeout(() => {
69
+                isCalled = false;
70
+                if (trailing) {
71
+                    fn(...args);
72
+                }
73
+            }, wait);
74
+
75
+            isCalled = true;
76
+        }
77
+    };
78
+}

正在加载...
取消
保存