From fdd4ba5fe73dfb7a5c664e70c823e272e5e5ee2b Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Fri, 31 Jan 2025 16:37:56 -0500 Subject: [PATCH] Fix panel hiding when hovering over it during delay #2083 --- src/intellihide.js | 71 ++++++++++++++++++++-------------------------- src/utils.js | 4 --- 2 files changed, 30 insertions(+), 45 deletions(-) diff --git a/src/intellihide.js b/src/intellihide.js index 4ccb762..3a76f5a 100644 --- a/src/intellihide.js +++ b/src/intellihide.js @@ -437,50 +437,39 @@ export const Intellihide = class { } _animatePanel(destination, immediate) { - let animating = Utils.isAnimating(this._panelBox, this._translationProp) + if (destination === this._animationDestination) return - if ( - !( - (animating && destination === this._animationDestination) || - (!animating && destination === this._panelBox[this._translationProp]) - ) - ) { - //the panel isn't already at, or animating to the asked destination - if (animating) { - Utils.stopAnimations(this._panelBox) + Utils.stopAnimations(this._panelBox) + this._animationDestination = destination + + if (immediate) { + this._panelBox[this._translationProp] = destination + this._panelBox.visible = !destination + } else if (destination !== this._panelBox[this._translationProp]) { + let tweenOpts = { + //when entering/leaving the overview, use its animation time instead of the one from the settings + time: Main.overview.visible + ? SIDE_CONTROLS_ANIMATION_TIME + : SETTINGS.get_int('intellihide-animation-time') * 0.001, + //only delay the animation when hiding the panel after the user hovered out + delay: + destination != 0 && this._hoveredOut + ? SETTINGS.get_int('intellihide-close-delay') * 0.001 + : 0, + transition: 'easeOutQuad', + onComplete: () => { + this._panelBox.visible = !destination + Main.layoutManager._queueUpdateRegions() + this._timeoutsHandler.add([ + T3, + POST_ANIMATE_MS, + () => this._queueUpdatePanelPosition(), + ]) + }, } - this._animationDestination = destination - - if (immediate) { - this._panelBox[this._translationProp] = destination - this._panelBox.visible = !destination - } else { - let tweenOpts = { - //when entering/leaving the overview, use its animation time instead of the one from the settings - time: Main.overview.visible - ? SIDE_CONTROLS_ANIMATION_TIME - : SETTINGS.get_int('intellihide-animation-time') * 0.001, - //only delay the animation when hiding the panel after the user hovered out - delay: - destination != 0 && this._hoveredOut - ? SETTINGS.get_int('intellihide-close-delay') * 0.001 - : 0, - transition: 'easeOutQuad', - onComplete: () => { - this._panelBox.visible = !destination - Main.layoutManager._queueUpdateRegions() - this._timeoutsHandler.add([ - T3, - POST_ANIMATE_MS, - () => this._queueUpdatePanelPosition(), - ]) - }, - } - - tweenOpts[this._translationProp] = destination - Utils.animate(this._panelBox, tweenOpts) - } + tweenOpts[this._translationProp] = destination + Utils.animate(this._panelBox, tweenOpts) } this._hoveredOut = false diff --git a/src/utils.js b/src/utils.js index 6ec78bf..f100a2c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -461,10 +461,6 @@ export const animate = function (actor, options) { actor.ease.apply(actor, params) } -export const isAnimating = function (actor, prop) { - return !!actor.get_transition(prop) -} - export const stopAnimations = function (actor) { actor.remove_all_transitions() }