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