@@ -85,7 +85,8 @@ namespace Stacks {
8585 disconnect ( ) {
8686 this . hide ( ) ;
8787 if ( this . floatingUI ) {
88- this . floatingUI . destroy ( ) ;
88+ // TODO: See if something similar is still necessary
89+ // this.floatingUI.destroy();
8990 delete this . floatingUI ;
9091 }
9192 super . disconnect ( ) ;
@@ -137,8 +138,9 @@ namespace Stacks {
137138 this . popoverElement . classList . remove ( "is-visible" ) ;
138139
139140 if ( this . floatingUI ) {
141+ // TODO: See if something similar is still necessary
140142 // completely destroy the popper on hide; this is in line with Popper.js's performance recommendations
141- this . floatingUI . destroy ( ) ;
143+ // this.floatingUI.destroy();
142144 delete this . floatingUI ;
143145 }
144146
@@ -181,28 +183,43 @@ namespace Stacks {
181183 * Initializes the Popper for this instance
182184 */
183185 private initializeFloatingUI ( ) {
186+ var popoverElement = this . popoverElement ;
187+ var arrowElement = popoverElement . querySelector ( ".s-popover--arrow" ) ;
184188 // @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+ } ) ;
206223 }
207224
208225 /**
@@ -267,7 +284,8 @@ namespace Stacks {
267284 */
268285 protected scheduleUpdate ( ) {
269286 if ( this . floatingUI && this . isVisible ) {
270- this . floatingUI . update ( ) ;
287+ // TODO reimplement update
288+ // this.floatingUI.update();
271289 }
272290 }
273291 }
0 commit comments