Browse Source

Fix tooltip for better performance.

pull/782/head
Sebastian 4 years ago
parent
commit
182cd79793
  1. 38
      frontend/app/framework/angular/modals/tooltip.directive.ts

38
frontend/app/framework/angular/modals/tooltip.directive.ts

@ -6,7 +6,7 @@
*/
import { Directive, ElementRef, HostListener, Input, OnDestroy, Renderer2 } from '@angular/core';
import { DialogService, Keys, Tooltip } from '@app/framework/internal';
import { DialogService, Tooltip } from '@app/framework/internal';
@Directive({
selector: '[title]:not(sqx-layout),[shortcut]',
@ -54,38 +54,6 @@ export class TooltipDirective implements OnDestroy {
this.hideShortcut();
}
@HostListener('body:keydown', ['$event'])
public onBodyKeyDown(event: KeyboardEvent) {
const shortcut = this.shortcut;
if (Keys.isControl(event) && shortcut && !this.shortcutTimer) {
this.shortcutTimer = setTimeout(() => {
this.showShortcut(shortcut);
}, this.shortcutDelay);
}
}
@HostListener('body:keyup')
public onBodyKeyUp() {
if (this.shortcutTimer) {
this.hideShortcut();
}
}
@HostListener('body:click')
public onBodyClick() {
if (this.shortcutTimer) {
this.hideShortcut();
}
}
@HostListener('window:blur')
public onWindowBlur() {
if (this.shortcutTimer) {
this.hideShortcut();
}
}
@HostListener('mouseenter')
public onMouseEnter() {
this.hide();
@ -139,10 +107,6 @@ export class TooltipDirective implements OnDestroy {
this.dialogs.tooltip(new Tooltip(this.target, this.titleText!, this.titlePosition, false, this.shortcut));
}
private showShortcut(shortcut: string) {
this.dialogs.tooltip(new Tooltip(this.target, shortcut, this.shortcutPosition, true));
}
private unsetAttribute() {
try {
this.renderer.setProperty(this.target, 'title', '');

Loading…
Cancel
Save