Change main toolbar animation; optimize mousemove handler

This commit is contained in:
Ilya Daynatovich 2016-10-25 14:55:43 +03:00
parent f271eb4610
commit 99d50ade11
5 changed files with 78 additions and 30 deletions

View File

@ -3,7 +3,7 @@
**/ **/
/** /**
* START of slide in animation for extended toolbar. * Slide in animation for extended toolbar.
*/ */
@include keyframes(slideInX) { @include keyframes(slideInX) {
0% { transform: translateX(-100%); } 0% { transform: translateX(-100%); }
@ -26,12 +26,9 @@
} }
/** /**
* END of slide out animation for extended toolbar. * Slide in / out animation for main toolbar.
*/ */
/**
* START of slide in / out animation for main toolbar.
*/
@include keyframes(slideInY) { @include keyframes(slideInY) {
100% { transform: translateY(0%); } 100% { transform: translateY(0%); }
} }
@ -42,11 +39,7 @@
} }
/** /**
* END of slide in / out animation for main toolbar. * Slide in animation for extended toolbar (inner) panel.
*/
/**
* START of slide in animation for extended toolbar (inner) panel.
*/ */
// FIX: Can't use percentage because of breaking animation when width is changed // FIX: Can't use percentage because of breaking animation when width is changed
@ -62,11 +55,7 @@
} }
/** /**
* END of slide in animation for extended toolbar (inner) panel. * Slide in animation for extended toolbar container
*/
/**
* START of slide in animation for extended toolbar container
**/ **/
@include keyframes(slideOutExtContainer) { @include keyframes(slideOutExtContainer) {
@ -80,5 +69,15 @@
} }
/** /**
* END of slide in animation for extended toolbar container * Fade in / out animations
**/ **/
@include keyframes(fadeIn) {
from { opacity: 0; }
to { opacity: 1; }
}
@include keyframes(fadeOut) {
from { opacity: 1; }
to { opacity: 0; }
}

View File

@ -16,8 +16,7 @@
z-index: $toolbarZ; z-index: $toolbarZ;
pointer-events: none; pointer-events: none;
min-height: 100px; min-height: 100px;
transform: translateY(-100%); opacity: 0;
-webkit-transform: translateY(-100%);
} }
#subject { #subject {
@ -273,5 +272,13 @@ a.button>#avatar {
} }
/** /**
* END of slide in animation for extended toolbar panel. * START of fade in animation for main toolbar
*/ */
.fadeIn {
@include animation('fadeIn .3s forwards');
}
.fadeOut {
@include animation('fadeOut .3s forwards');
}

View File

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

View File

@ -610,7 +610,7 @@ Toolbar = {
* @return <tt>true</tt> if currently visible, <tt>false</tt> - otherwise * @return <tt>true</tt> if currently visible, <tt>false</tt> - otherwise
*/ */
isVisible() { isVisible() {
return this.toolbarSelector.hasClass("slideInY"); return this.toolbarSelector.hasClass("fadeIn");
}, },
/** /**
@ -618,7 +618,9 @@ Toolbar = {
* parameter. * parameter.
*/ */
hide() { hide() {
this.toolbarSelector.toggleClass("slideInY").toggleClass("slideOutY"); this.toolbarSelector
.removeClass("fadeIn")
.addClass("fadeOut");
let slideInAnimation = (SideContainerToggler.isVisible) let slideInAnimation = (SideContainerToggler.isVisible)
? "slideInExtX" ? "slideInExtX"
@ -636,8 +638,9 @@ Toolbar = {
* parameter. * parameter.
*/ */
show() { show() {
if (this.toolbarSelector.hasClass("slideOutY")) if (this.toolbarSelector.hasClass("fadeOut")) {
this.toolbarSelector.toggleClass("slideOutY"); this.toolbarSelector.removeClass("fadeOut");
}
let slideInAnimation = (SideContainerToggler.isVisible) let slideInAnimation = (SideContainerToggler.isVisible)
? "slideInExtX" ? "slideInExtX"
@ -646,10 +649,11 @@ Toolbar = {
? "slideOutExtX" ? "slideOutExtX"
: "slideOutX"; : "slideOutX";
if (this.extendedToolbarSelector.hasClass(slideOutAnimation)) if (this.extendedToolbarSelector.hasClass(slideOutAnimation)) {
this.extendedToolbarSelector.toggleClass(slideOutAnimation); this.extendedToolbarSelector.toggleClass(slideOutAnimation);
}
this.toolbarSelector.toggleClass("slideInY"); this.toolbarSelector.addClass("fadeIn");
this.extendedToolbarSelector.toggleClass(slideInAnimation); this.extendedToolbarSelector.toggleClass(slideInAnimation);
}, },

View File

@ -40,3 +40,39 @@ export function reportError (e, msg = "") {
window.onerror(msg, null, null, window.onerror(msg, null, null,
null, e); null, e);
} }
/**
* Creates a debounced function that delays invoking func until after wait
* milliseconds have elapsed since the last time the debounced
* function was invoked
* @param fn
* @param wait
* @param options
* @returns {function(...[*])}
*/
export function debounce(fn, wait = 0, options = {}) {
let leading = options.leading || false;
let trailing = true;
let isCalled = false;
if (typeof options.trailing !== 'undefined') {
trailing = options.trailing;
}
return (...args) => {
if(!isCalled) {
if (leading) {
fn(...args);
}
setTimeout(() => {
isCalled = false;
if (trailing) {
fn(...args);
}
}, wait);
isCalled = true;
}
};
}