]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Only disable animation when element is displayed
authorSamuel Mannehed <samuel@cendio.se>
Thu, 8 Mar 2018 15:52:53 +0000 (16:52 +0100)
committerSamuel Mannehed <samuel@cendio.se>
Thu, 8 Mar 2018 15:52:53 +0000 (16:52 +0100)
The transitionend event will not fire when display=none. This can
prevent the initial animation for hiding the controlbar in some cases.

app/ui.js

index 592dfcf77706b0e8b5fcff39c9a106e0f6239d19..4e301d4e4a812e5567d4a5d1b792b99043b3a061 100644 (file)
--- a/app/ui.js
+++ b/app/ui.js
@@ -549,10 +549,15 @@ var UI = {
     },
 
     toggleControlbarSide: function () {
-        // Temporarily disable animation to avoid weird movement
+        // Temporarily disable animation, if bar is displayed, to avoid weird
+        // movement. The transitionend-event will not fire when display=none.
         var bar = document.getElementById('noVNC_control_bar');
-        bar.style.transitionDuration = '0s';
-        bar.addEventListener('transitionend', function () { this.style.transitionDuration = ""; });
+        var barDisplayStyle = window.getComputedStyle(bar).display;
+        if (barDisplayStyle !== 'none') {
+            bar.style.transitionDuration = '0s';
+            bar.addEventListener('transitionend', function () {
+                this.style.transitionDuration = ""; });
+        }
 
         var anchor = document.getElementById('noVNC_control_bar_anchor');
         if (anchor.classList.contains("noVNC_right")) {