From 36cff235c26581933b44bd1877f11e5c036632b3 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 16 Jul 2021 06:00:29 -0700 Subject: [PATCH] Show hover immediately when moving from related icons Fixes #122226 --- .../browser/parts/compositeBarActions.ts | 18 +++++++++++++----- .../workbench/services/hover/browser/hover.ts | 6 ++++++ .../services/hover/browser/hoverWidget.ts | 3 +++ .../services/hover/browser/media/hover.css | 5 ++++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/browser/parts/compositeBarActions.ts b/src/vs/workbench/browser/parts/compositeBarActions.ts index 3c431e12974..81e54aa5abe 100644 --- a/src/vs/workbench/browser/parts/compositeBarActions.ts +++ b/src/vs/workbench/browser/parts/compositeBarActions.ts @@ -152,6 +152,8 @@ export class ActivityActionViewItem extends BaseActionViewItem { private readonly hover = this._register(new MutableDisposable()); private readonly showHoverScheduler = new RunOnceScheduler(() => this.showHover(), 0); + private static _hoverLeaveTime = 0; + constructor( action: ActivityAction, options: IActivityActionViewItemOptions, @@ -387,12 +389,17 @@ export class ActivityActionViewItem extends BaseActionViewItem { this.hoverDisposables.clear(); this.updateTitle(); - this.hoverDisposables.add(addDisposableListener(this.container, EventType.MOUSE_OVER, () => { + this.hoverDisposables.add(addDisposableListener(this.label, EventType.MOUSE_OVER, () => { if (!this.showHoverScheduler.isScheduled()) { - this.showHoverScheduler.schedule(this.configurationService.getValue('workbench.hover.delay')); + if (Date.now() - ActivityActionViewItem._hoverLeaveTime < 200) { + this.showHover(true); + } else { + this.showHoverScheduler.schedule(this.configurationService.getValue('workbench.hover.delay')); + } } }, true)); - this.hoverDisposables.add(addDisposableListener(this.container, EventType.MOUSE_LEAVE, () => { + this.hoverDisposables.add(addDisposableListener(this.label, EventType.MOUSE_LEAVE, () => { + ActivityActionViewItem._hoverLeaveTime = Date.now(); this.hover.value = undefined; this.showHoverScheduler.cancel(); }, true)); @@ -402,7 +409,7 @@ export class ActivityActionViewItem extends BaseActionViewItem { })); } - private showHover(): void { + private showHover(skipFadeInAnimation: boolean = false): void { if (this.hover.value) { return; } @@ -412,7 +419,8 @@ export class ActivityActionViewItem extends BaseActionViewItem { hoverPosition, text: this.computeTitle(), showPointer: true, - compact: true + compact: true, + skipFadeInAnimation }); } diff --git a/src/vs/workbench/services/hover/browser/hover.ts b/src/vs/workbench/services/hover/browser/hover.ts index 4b537f17a0b..628beb67cc6 100644 --- a/src/vs/workbench/services/hover/browser/hover.ts +++ b/src/vs/workbench/services/hover/browser/hover.ts @@ -96,6 +96,12 @@ export interface IHoverOptions { * Whether to show a compact hover */ compact?: boolean; + + /** + * Whether to skip the fade in animation, this should be used when hovering from one hover to + * another in the same group so it looks like the hover is moving from one element to the other. + */ + skipFadeInAnimation?: boolean; } export interface IHoverAction { diff --git a/src/vs/workbench/services/hover/browser/hoverWidget.ts b/src/vs/workbench/services/hover/browser/hoverWidget.ts index 30624f1b651..d5b0010536e 100644 --- a/src/vs/workbench/services/hover/browser/hoverWidget.ts +++ b/src/vs/workbench/services/hover/browser/hoverWidget.ts @@ -82,6 +82,9 @@ export class HoverWidget extends Widget { if (options.compact) { this._hover.containerDomNode.classList.add('workbench-hover', 'compact'); } + if (options.skipFadeInAnimation) { + this._hover.containerDomNode.classList.add('skip-fade-in'); + } if (options.additionalClasses) { this._hover.containerDomNode.classList.add(...options.additionalClasses); } diff --git a/src/vs/workbench/services/hover/browser/media/hover.css b/src/vs/workbench/services/hover/browser/media/hover.css index 3f99afce89e..215cb9b9fcc 100644 --- a/src/vs/workbench/services/hover/browser/media/hover.css +++ b/src/vs/workbench/services/hover/browser/media/hover.css @@ -7,13 +7,16 @@ position: relative; font-size: 13px; line-height: 19px; - animation: fadein 100ms linear; /* Must be higher than sash's z-index and terminal canvases */ z-index: 40; overflow: hidden; max-width: 700px; } +.monaco-workbench .workbench-hover:not(.skip-fade-in) { + animation: fadein 100ms linear; +} + .monaco-workbench .workbench-hover.compact { font-size: 12px; }