|
3 | 3 | OnDestroy, inject, DOCUMENT, HostListener, |
4 | 4 | } from '@angular/core'; |
5 | 5 | import { IgxOverlayService } from '../../services/overlay/overlay'; |
| 6 | +import { OverlaySettings } from '../../services/overlay/utilities'; |
6 | 7 | import { IgxNavigationService } from '../../core/navigation'; |
7 | 8 | import { IgxToggleDirective } from '../toggle/toggle.directive'; |
8 | 9 | import { IgxTooltipTargetDirective } from './tooltip-target.directive'; |
@@ -165,29 +166,43 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy |
165 | 166 |
|
166 | 167 | /** |
167 | 168 | * If there is an animation in progress, this method will reset it to its initial state. |
168 | | - * Optional `force` parameter that ends the animation. |
| 169 | + * Allows hovering over the tooltip while an open/close animation is running. |
| 170 | + * Stops the animation and immediately shows the tooltip. |
169 | 171 | * |
170 | 172 | * @hidden |
171 | | - * @param force if set to `true`, the animation will be ended. |
172 | 173 | */ |
173 | | - public stopAnimations(force: boolean = false): void { |
| 174 | + public stopAnimations(): void { |
174 | 175 | const info = this.overlayService.getOverlayById(this._overlayId); |
175 | 176 |
|
176 | 177 | if (!info) return; |
177 | 178 |
|
178 | 179 | if (info.openAnimationPlayer) { |
179 | 180 | info.openAnimationPlayer.reset(); |
180 | | - if (force) { |
181 | | - info.openAnimationPlayer.finish(); |
182 | | - info.openAnimationPlayer = null; |
183 | | - } |
184 | 181 | } |
185 | 182 | if (info.closeAnimationPlayer) { |
186 | 183 | info.closeAnimationPlayer.reset(); |
187 | | - if (force) { |
188 | | - info.closeAnimationPlayer.finish(); |
189 | | - info.closeAnimationPlayer = null; |
190 | | - } |
| 184 | + } |
| 185 | + } |
| 186 | + |
| 187 | + /** |
| 188 | + * If there is a close animation in progress, this method will end it. |
| 189 | + * If there is no close animation in progress, this method will close the tooltip with no animation. |
| 190 | + * |
| 191 | + * @param overlaySettings settings to use for closing the tooltip |
| 192 | + * @hidden |
| 193 | + */ |
| 194 | + public forceClose(overlaySettings: OverlaySettings) { |
| 195 | + const info = this.overlayService.getOverlayById(this._overlayId); |
| 196 | + |
| 197 | + if (info && info.closeAnimationPlayer) { |
| 198 | + info.closeAnimationPlayer.finish(); |
| 199 | + info.closeAnimationPlayer.reset(); |
| 200 | + info.closeAnimationPlayer = null; |
| 201 | + } else if (!this.collapsed) { |
| 202 | + const animation = overlaySettings.positionStrategy.settings.closeAnimation; |
| 203 | + overlaySettings.positionStrategy.settings.closeAnimation = null; |
| 204 | + this.close(); |
| 205 | + overlaySettings.positionStrategy.settings.closeAnimation = animation; |
191 | 206 | } |
192 | 207 | } |
193 | 208 |
|
|
0 commit comments