瀏覽代碼

Change main toolbar animation; optimize mousemove handler

master
Ilya Daynatovich 8 年之前
父節點
當前提交
99d50ade11
共有 5 個檔案被更改,包括 78 行新增30 行删除
  1. 16
    17
      css/_animations.scss
  2. 10
    3
      css/_toolbars.scss
  3. 6
    4
      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,7 +3,7 @@
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 8
 @include keyframes(slideInX) {
9 9
     0% { transform: translateX(-100%); }
@@ -26,12 +26,9 @@
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 32
 @include keyframes(slideInY) {
36 33
     100% { transform: translateY(0%); }
37 34
 }
@@ -42,11 +39,7 @@
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 45
 // FIX: Can't use percentage because of breaking animation when width is changed
@@ -62,11 +55,7 @@
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 61
 @include keyframes(slideOutExtContainer) {
@@ -80,5 +69,15 @@
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,8 +16,7 @@
16 16
     z-index: $toolbarZ;
17 17
     pointer-events: none;
18 18
     min-height: 100px;
19
-    transform: translateY(-100%);
20
-    -webkit-transform: translateY(-100%);
19
+    opacity: 0;
21 20
 }
22 21
 
23 22
 #subject {
@@ -273,5 +272,13 @@ a.button>#avatar {
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
+}

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

@@ -22,6 +22,7 @@ import Profile from "./side_pannels/profile/Profile";
22 22
 import Settings from "./../settings/Settings";
23 23
 import RingOverlay from "./ring_overlay/RingOverlay";
24 24
 import UIErrors from './UIErrors';
25
+import { debounce } from "../util/helpers";
25 26
 
26 27
 var EventEmitter = require("events");
27 28
 UI.messageHandler = require("./util/MessageHandler");
@@ -438,9 +439,10 @@ UI.start = function () {
438 439
     bindEvents();
439 440
     sharedVideoManager = new SharedVideoManager(eventEmitter);
440 441
     if (!interfaceConfig.filmStripOnly) {
441
-        $("#videoconference_page").mousemove(function () {
442
-            return UI.showToolbar();
443
-        });
442
+        let debouncedShowToolbar = debounce(() => {
443
+            UI.showToolbar();
444
+        }, 100, { leading: true, trailing: false });
445
+        $("#videoconference_page").mousemove(debouncedShowToolbar);
444 446
         setupToolbars();
445 447
         setupChat();
446 448
 
@@ -1046,7 +1048,7 @@ UI.updateDTMFSupport = function (isDTMFSupported) {
1046 1048
  * @returns {Promise} Resolved with value - false if the dialog is enabled and
1047 1049
  * resolved with true if the dialog is disabled or the feedback was already
1048 1050
  * submitted. Rejected if another dialog is already displayed. This values are
1049
- * used to display or not display the thank you dialog from 
1051
+ * used to display or not display the thank you dialog from
1050 1052
  * conference.maybeRedirectToWelcomePage method.
1051 1053
  */
1052 1054
 UI.requestFeedbackOnHangup = function () {

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

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

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

@@ -40,3 +40,39 @@ export function reportError (e, msg = "") {
40 40
         window.onerror(msg, null, null,
41 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
+}

Loading…
取消
儲存