11import { useAnimation } from '@angular/animations' ;
2- import { Directive , OnInit , OnDestroy , Output , ElementRef , Optional , ViewContainerRef , HostListener , Input , EventEmitter , booleanAttribute , TemplateRef , ComponentRef , Renderer2 , AfterViewInit } from '@angular/core' ;
2+ import {
3+ Directive , OnInit , OnDestroy , Output , ElementRef , Optional , ViewContainerRef , HostListener ,
4+ Input , EventEmitter , booleanAttribute , TemplateRef , ComponentRef , Renderer2 , OnChanges , SimpleChanges ,
5+ } from '@angular/core' ;
36import { Subject } from 'rxjs' ;
47import { takeUntil } from 'rxjs/operators' ;
58import { IgxNavigationService } from '../../core/navigation' ;
69import { IBaseEventArgs } from '../../core/utils' ;
7- import { PositionSettings } from '../../services/public_api' ;
10+ import { PositionSettings } from '../../services/public_api' ;
811import { IgxToggleActionDirective } from '../toggle/toggle.directive' ;
912import { IgxTooltipComponent } from './tooltip.component' ;
1013import { IgxTooltipDirective } from './tooltip.directive' ;
1114import { IgxTooltipCloseButtonComponent } from './tooltip-close-button.component' ;
1215import { fadeOut , scaleInCenter } from 'igniteui-angular/animations' ;
1316import { TooltipPlacement } from './enums' ;
14- import { IgxTooltipPositionStrategy , PositionsMap , TooltipRegexes } from './tooltip.common' ;
15- import { IgxDirectionality } from '../../services/direction/directionality' ;
17+ import { TooltipPositionStrategy , PositionsMap } from './tooltip.common' ;
1618
1719export interface ITooltipShowEventArgs extends IBaseEventArgs {
1820 target : IgxTooltipTargetDirective ;
@@ -44,12 +46,7 @@ export interface ITooltipHideEventArgs extends IBaseEventArgs {
4446 selector : '[igxTooltipTarget]' ,
4547 standalone : true
4648} )
47- export class IgxTooltipTargetDirective extends IgxToggleActionDirective implements OnInit , AfterViewInit , OnDestroy {
48-
49- private _closeButtonRef ?: ComponentRef < IgxTooltipCloseButtonComponent > ;
50- private _closeTemplate : TemplateRef < any > ;
51- private _sticky = false ;
52-
49+ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implements OnChanges , OnInit , OnDestroy {
5350 /**
5451 * Gets/sets the amount of milliseconds that should pass before showing the tooltip.
5552 *
@@ -97,8 +94,7 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
9794 this . _placement = value ;
9895
9996 if ( this . _overlayDefaults && this . target ) {
100- this . _overlayDefaults . positionStrategy = new IgxTooltipPositionStrategy ( this . _positionsSettingsByPlacement , value , this . offset ) ;
101- this . target . positionArrow ( value , this . _arrowOffset ) ;
97+ this . _overlayDefaults . positionStrategy = new TooltipPositionStrategy ( this . _positionsSettingsByPlacement , this ) ;
10298 }
10399 }
104100
@@ -108,7 +104,17 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
108104
109105 /** The offset of the tooltip from the target in pixels. Default value is 6. */
110106 @Input ( )
111- public offset = 6 ;
107+ public set offset ( value : number ) {
108+ this . _offset = value ;
109+
110+ if ( this . _overlayDefaults && this . target ) {
111+ this . _overlayDefaults . positionStrategy = new TooltipPositionStrategy ( this . _positionsSettingsByPlacement , this ) ;
112+ }
113+ }
114+
115+ public get offset ( ) : number {
116+ return this . _offset ;
117+ }
112118
113119 /**
114120 * Controls whether the arrow element of the tooltip is rendered.
@@ -131,11 +137,14 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
131137 */
132138 @Input ( )
133139 public set disableArrow ( value : boolean ) {
134- this . target . disableArrow = value ;
140+ if ( this . target ) {
141+ this . target . arrow . style . display = value ? 'none' : '' ;
142+ }
143+ this . _disableArrow = value ;
135144 }
136145
137146 public get disableArrow ( ) : boolean {
138- return this . target . disableArrow ;
147+ return this . _disableArrow ;
139148 }
140149
141150 /**
@@ -314,14 +323,18 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
314323 private _destroy$ = new Subject < void > ( ) ;
315324 private _autoHideDelay = 180 ;
316325 private _isForceClosed = false ;
326+ private _disableArrow = false ;
327+ private _offset = 6 ;
317328 private _placement : TooltipPlacement = TooltipPlacement . top ;
329+ private _closeButtonRef ?: ComponentRef < IgxTooltipCloseButtonComponent > ;
330+ private _closeTemplate : TemplateRef < any > ;
331+ private _sticky = false ;
318332
319333 constructor (
320334 private _element : ElementRef ,
321335 @Optional ( ) private _navigationService : IgxNavigationService ,
322336 private _viewContainerRef : ViewContainerRef ,
323337 private _renderer : Renderer2 ,
324- private _dir : IgxDirectionality ,
325338 ) {
326339 super ( _element , _navigationService ) ;
327340 }
@@ -395,13 +408,23 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
395408 }
396409 }
397410
411+
412+ /**
413+ * @hidden
414+ */
415+ public ngOnChanges ( changes : SimpleChanges ) : void {
416+ if ( changes [ 'disableArrow' ] ) {
417+ this . target . arrow . style . display = changes [ 'disableArrow' ] . currentValue ? 'none' : '' ;
418+ }
419+ }
420+
398421 /**
399422 * @hidden
400423 */
401424 public override ngOnInit ( ) {
402425 super . ngOnInit ( ) ;
403426
404- this . _overlayDefaults . positionStrategy = new IgxTooltipPositionStrategy ( this . _positionsSettingsByPlacement , this . placement , this . offset ) ;
427+ this . _overlayDefaults . positionStrategy = new TooltipPositionStrategy ( this . _positionsSettingsByPlacement , this ) ;
405428 this . _overlayDefaults . closeOnOutsideClick = false ;
406429 this . _overlayDefaults . closeOnEscape = true ;
407430
@@ -418,13 +441,6 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
418441 this . target . onHide = this . _hideOnInteraction . bind ( this ) ;
419442 }
420443
421- /**
422- * @hidden
423- */
424- public ngAfterViewInit ( ) {
425- this . target . positionArrow ( this . placement , this . _arrowOffset ) ;
426- }
427-
428444 /**
429445 * @hidden
430446 */
@@ -468,27 +484,6 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
468484 return Object . assign ( { } , animations , positions ) ;
469485 }
470486
471- private get _arrowOffset ( ) : number {
472- if ( this . placement . includes ( '-' ) ) {
473- // Horizontal start | end placement
474- if ( TooltipRegexes . horizontalStart . test ( this . placement ) ) {
475- return - 8 ;
476- }
477- if ( TooltipRegexes . horizontalEnd . test ( this . placement ) ) {
478- return 8 ;
479- }
480-
481- // Vertical start | end placement
482- if ( TooltipRegexes . start . test ( this . placement ) ) {
483- return this . _dir . rtl ? 8 : - 8 ;
484- }
485- if ( TooltipRegexes . end . test ( this . placement ) ) {
486- return this . _dir . rtl ? - 8 : 8 ;
487- }
488- }
489- return 0 ;
490- }
491-
492487 private _checkOutletAndOutsideClick ( ) : void {
493488 if ( this . outlet ) {
494489 this . _overlayDefaults . outlet = this . outlet ;
0 commit comments