@@ -85,7 +85,8 @@ namespace Stacks {
85
85
disconnect ( ) {
86
86
this . hide ( ) ;
87
87
if ( this . floatingUI ) {
88
- this . floatingUI . destroy ( ) ;
88
+ // TODO: See if something similar is still necessary
89
+ // this.floatingUI.destroy();
89
90
delete this . floatingUI ;
90
91
}
91
92
super . disconnect ( ) ;
@@ -137,8 +138,9 @@ namespace Stacks {
137
138
this . popoverElement . classList . remove ( "is-visible" ) ;
138
139
139
140
if ( this . floatingUI ) {
141
+ // TODO: See if something similar is still necessary
140
142
// completely destroy the popper on hide; this is in line with Popper.js's performance recommendations
141
- this . floatingUI . destroy ( ) ;
143
+ // this.floatingUI.destroy();
142
144
delete this . floatingUI ;
143
145
}
144
146
@@ -181,28 +183,43 @@ namespace Stacks {
181
183
* Initializes the Popper for this instance
182
184
*/
183
185
private initializeFloatingUI ( ) {
186
+ var popoverElement = this . popoverElement ;
187
+ var arrowElement = popoverElement . querySelector ( ".s-popover--arrow" ) ;
184
188
// @ts -ignore
185
- // this.floatingUI = FloatingUICore.computePosition(this.refrenceElement, this.popoverElement, {
186
- // // @ts -ignore
187
- // middleware: [ FloatingUICore.offset(), FloatingUICore.flip(), FloatingUICore.shift() ]
188
- // });
189
- // this.floatingUI = FloatingUICore.createPopper(this.referenceElement, this.popoverElement, {
190
- // placement: this.data.get("placement") || "bottom",
191
- // modifiers: [
192
- // {
193
- // name: "offset",
194
- // options: {
195
- // offset: [0, 10], // The entire popover should be 10px away from the element
196
- // }
197
- // },
198
- // {
199
- // name: "arrow",
200
- // options: {
201
- // element: ".s-popover--arrow"
202
- // },
203
- // },
204
- // ]
205
- // });
189
+ this . floatingUI = FloatingUIDOM . computePosition ( this . referenceElement , popoverElement , {
190
+ placement : this . data . get ( "placement" ) || "bottom" ,
191
+ middleware : [
192
+ // @ts -ignore
193
+ FloatingUIDOM . offset ( 10 ) , FloatingUIDOM . flip ( ) , FloatingUIDOM . shift ( { padding : 10 } ) ,
194
+ // @ts -ignore
195
+ FloatingUIDOM . arrow ( { element : arrowEl } ) ,
196
+ ] ,
197
+ // @ts -ignore
198
+ } ) . then ( ( { middlewareData, placement, x, y} ) => {
199
+ const { x : arrowX , y : arrowY } = middlewareData . arrow ;
200
+
201
+ Object . assign ( popoverElement . style , {
202
+ left : `${ x } px` ,
203
+ top : `${ y } px` ,
204
+ } ) ;
205
+
206
+ // @ts -ignore
207
+ const staticSide = {
208
+ top : 'bottom' ,
209
+ right : 'left' ,
210
+ bottom : 'top' ,
211
+ left : 'right' ,
212
+ } [ placement . split ( '-' ) [ 0 ] ] ;
213
+
214
+ if ( arrowElement ) {
215
+ // @ts -ignore
216
+ Object . assign ( arrowElement . style , {
217
+ // TODO: Fix arrow positioning
218
+ transform : `translateX(${ ( arrowX || 0 ) } px) translateY(${ ( arrowY || 0 ) } px)` ,
219
+ [ staticSide ] : '-4px' ,
220
+ } ) ;
221
+ }
222
+ } ) ;
206
223
}
207
224
208
225
/**
@@ -267,7 +284,8 @@ namespace Stacks {
267
284
*/
268
285
protected scheduleUpdate ( ) {
269
286
if ( this . floatingUI && this . isVisible ) {
270
- this . floatingUI . update ( ) ;
287
+ // TODO reimplement update
288
+ // this.floatingUI.update();
271
289
}
272
290
}
273
291
}
0 commit comments