@@ -40,10 +40,11 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
40
40
*/
41
41
@Input ( 'cPopoverOptions' )
42
42
set popperOptions ( value : Partial < Options > ) {
43
- this . _popperOptions = { ...this . _popperOptions , placement : this . placement , ...value } ;
43
+ this . _popperOptions = { ...this . _popperOptions , placement : this . placement , ...value } ;
44
44
} ;
45
+
45
46
get popperOptions ( ) : Partial < Options > {
46
- return { placement : this . placement , ...this . _popperOptions } ;
47
+ return { placement : this . placement , ...this . _popperOptions } ;
47
48
}
48
49
49
50
/**
@@ -63,11 +64,17 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
63
64
set visible ( value : boolean ) {
64
65
this . _visible = value ;
65
66
}
67
+
66
68
get visible ( ) {
67
69
return this . _visible ;
68
70
}
71
+
69
72
private _visible = false ;
70
73
74
+ @HostBinding ( 'attr.aria-describedby' ) get ariaDescribedBy ( ) : string | null {
75
+ return this . popoverId ? this . popoverId : null ;
76
+ }
77
+
71
78
private popover ! : HTMLDivElement ;
72
79
private popoverId ! : string ;
73
80
private popoverRef ! : ComponentRef < PopoverComponent > ;
@@ -78,10 +85,10 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
78
85
{
79
86
name : 'offset' ,
80
87
options : {
81
- offset : [ 0 , 8 ] ,
82
- } ,
83
- } ,
84
- ] ,
88
+ offset : [ 0 , 8 ]
89
+ }
90
+ }
91
+ ]
85
92
} ;
86
93
87
94
constructor (
@@ -99,17 +106,12 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
99
106
}
100
107
}
101
108
102
- @HostBinding ( 'attr.aria-describedby' ) get ariaDescribedBy ( ) : string | null {
103
- return this . popoverId ? this . popoverId : null ;
104
- }
105
-
106
109
ngOnDestroy ( ) : void {
107
110
this . clearListeners ( ) ;
108
111
this . destroyPopoverElement ( ) ;
109
112
}
110
113
111
114
ngOnInit ( ) : void {
112
- // this.createPopoverElement();
113
115
this . setListeners ( ) ;
114
116
}
115
117
@@ -129,8 +131,8 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
129
131
this . visible = true ;
130
132
this . addPopoverElement ( ) ;
131
133
}
132
- }
133
- this . listenersService . setListeners ( config )
134
+ } ;
135
+ this . listenersService . setListeners ( config ) ;
134
136
}
135
137
136
138
private clearListeners ( ) : void {
@@ -171,38 +173,33 @@ export class PopoverDirective implements OnChanges, OnDestroy, OnInit {
171
173
this . popoverRef . instance . content = this . content ;
172
174
this . popover = this . popoverRef . location . nativeElement ;
173
175
this . renderer . addClass ( this . popover , 'fade' ) ;
174
- // this.renderer.setStyle(this.popover, 'visibility', 'hidden')
175
176
176
177
setTimeout ( ( ) => {
177
178
this . popperInstance = createPopper (
178
179
this . hostElement . nativeElement ,
179
180
this . popover ,
180
- { ...this . popperOptions }
181
+ { ...this . popperOptions }
181
182
) ;
182
183
this . viewContainerRef . insert ( this . popoverRef . hostView ) ;
183
184
setTimeout ( ( ) => {
184
185
this . popoverId = this . getUID ( 'popover' ) ;
185
186
this . popoverRef . instance . id = this . popoverId ;
186
187
this . popoverRef . instance . visible = this . visible ;
187
- // this.renderer.removeStyle(this.popover, 'visibility');
188
188
this . renderer . appendChild ( this . document . body , this . popover ) ;
189
189
this . popperInstance . forceUpdate ( ) ;
190
- // this.popoverRef.changeDetectorRef.detectChanges ();
190
+ // this.popoverRef.changeDetectorRef.markForCheck ();
191
191
} , 100 ) ;
192
- } )
192
+ } ) ;
193
193
}
194
194
195
195
private removePopoverElement ( ) : void {
196
196
if ( ! this . popoverRef ) {
197
197
return ;
198
198
}
199
199
this . popoverRef . instance . visible = this . visible ;
200
- // this.popoverRef.changeDetectorRef?.detectChanges();
201
200
this . popoverRef . instance . id = undefined ;
202
201
setTimeout ( ( ) => {
203
202
this . viewContainerRef . detach ( ) ;
204
- // this.viewContainerRef.remove();
205
- // this.renderer.removeChild(this.document.body, this.popover);
206
203
this . popperInstance ?. destroy ( ) ;
207
204
this . popoverId = '' ;
208
205
} , 300 ) ;
0 commit comments