Browse Source

Change main toolbar animation; optimize mousemove handler

j8
Ilya Daynatovich 9 years ago
parent
commit
99d50ade11
5 changed files with 78 additions and 30 deletions
  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 View File

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 View File

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
+}

+ 6
- 4
modules/UI/UI.js View File

22
 import Settings from "./../settings/Settings";
22
 import Settings from "./../settings/Settings";
23
 import RingOverlay from "./ring_overlay/RingOverlay";
23
 import RingOverlay from "./ring_overlay/RingOverlay";
24
 import UIErrors from './UIErrors';
24
 import UIErrors from './UIErrors';
25
+import { debounce } from "../util/helpers";
25
 
26
 
26
 var EventEmitter = require("events");
27
 var EventEmitter = require("events");
27
 UI.messageHandler = require("./util/MessageHandler");
28
 UI.messageHandler = require("./util/MessageHandler");
438
     bindEvents();
439
     bindEvents();
439
     sharedVideoManager = new SharedVideoManager(eventEmitter);
440
     sharedVideoManager = new SharedVideoManager(eventEmitter);
440
     if (!interfaceConfig.filmStripOnly) {
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
         setupToolbars();
446
         setupToolbars();
445
         setupChat();
447
         setupChat();
446
 
448
 
1046
  * @returns {Promise} Resolved with value - false if the dialog is enabled and
1048
  * @returns {Promise} Resolved with value - false if the dialog is enabled and
1047
  * resolved with true if the dialog is disabled or the feedback was already
1049
  * resolved with true if the dialog is disabled or the feedback was already
1048
  * submitted. Rejected if another dialog is already displayed. This values are
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
  * conference.maybeRedirectToWelcomePage method.
1052
  * conference.maybeRedirectToWelcomePage method.
1051
  */
1053
  */
1052
 UI.requestFeedbackOnHangup = function () {
1054
 UI.requestFeedbackOnHangup = function () {

+ 10
- 6
modules/UI/toolbars/Toolbar.js View File

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

+ 36
- 0
modules/util/helpers.js View File

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
+}

Loading…
Cancel
Save