diff --git a/projects/fab-speed-dial/src/lib/fab-speed-dial.ts b/projects/fab-speed-dial/src/lib/fab-speed-dial.ts index 39c19c3..10ae315 100644 --- a/projects/fab-speed-dial/src/lib/fab-speed-dial.ts +++ b/projects/fab-speed-dial/src/lib/fab-speed-dial.ts @@ -17,6 +17,7 @@ import { ViewEncapsulation, } from '@angular/core'; import {MatButton} from '@angular/material/button'; +import {MatTooltip} from '@angular/material/tooltip'; import {CommonModule, DOCUMENT} from '@angular/common'; import {forkJoin, fromEvent, Subscription} from 'rxjs'; import {take} from 'rxjs/operators'; @@ -36,6 +37,7 @@ export class EcoFabSpeedDialActionsComponent implements AfterContentInit { private _parent: EcoFabSpeedDialComponent; @ContentChildren(MatButton) private _buttons!: QueryList; + @ContentChildren(MatTooltip) private _tooltips!: QueryList; /** * Whether the min-fab button exist in DOM @@ -97,15 +99,15 @@ export class EcoFabSpeedDialActionsComponent implements AfterContentInit { this.changeElementStyle(hostElement, 'opacity', '1'); this.changeElementStyle(hostElement, 'transform', transform); }); - }, 50); // Be sure that *ngIf can show elements before trying to animate them - } - private resetAnimationState(): void { - clearTimeout(this.showMiniFabAnimation); - if (this.hideMiniFab) { - this.hideMiniFab.unsubscribe(); - this.hideMiniFab = null; - } + setTimeout(() => { + this._tooltips.forEach(tooltip => { + if (this.miniFabVisible) { + tooltip.show(); + } + }); + }, 500); + }, 50); // Be sure that *ngIf can show elements before trying to animate them } public hide(): void { @@ -115,6 +117,8 @@ export class EcoFabSpeedDialActionsComponent implements AfterContentInit { this.resetAnimationState(); + this._tooltips.map(tooltip => tooltip.hide()); + const obs = this._buttons.map((button, i) => { let opacity = '1'; let transitionDelay = 0; @@ -141,6 +145,14 @@ export class EcoFabSpeedDialActionsComponent implements AfterContentInit { this.hideMiniFab = forkJoin(obs).subscribe(() => (this.miniFabVisible = false)); } + private resetAnimationState(): void { + clearTimeout(this.showMiniFabAnimation); + if (this.hideMiniFab) { + this.hideMiniFab.unsubscribe(); + this.hideMiniFab = null; + } + } + private getTranslateFunction(value: string): string { const dir = this._parent.direction; const translateFn = dir === 'up' || dir === 'down' ? 'translateY' : 'translateX'; diff --git a/src/app/app.component.html b/src/app/app.component.html index dac9b7f..f3810f8 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -19,6 +19,15 @@ Right

+

+ Tooltip position: + + After + Before + Above + Below + +

Animation Mode: @@ -46,13 +55,28 @@ - - - @@ -76,13 +100,28 @@ - - - diff --git a/src/app/app.component.ts b/src/app/app.component.ts index ff9c2e1..1b8f56c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,5 @@ import {Component} from '@angular/core'; +import {TooltipPosition} from '@angular/material/tooltip'; import {AnimationMode, Direction} from '@ecodev/fab-speed-dial'; @Component({ @@ -15,6 +16,7 @@ export class AppComponent { public spin = false; public direction: Direction = 'up'; public animationMode: AnimationMode = 'fling'; + public tooltipPosition: TooltipPosition = 'after'; public get fixed(): boolean { return this._fixed;