@@ -11,7 +11,6 @@ import hasMoved from '../utils/has-moved.ts';
1111import { isTesting } from '@embroider/macros' ;
1212import { modifier } from 'ember-modifier' ;
1313import type { Dropdown , TRootEventType } from './basic-dropdown.ts' ;
14- import { runTask } from 'ember-lifeline' ;
1514
1615export interface BasicDropdownContentSignature {
1716 Element : Element ;
@@ -205,11 +204,8 @@ export default class BasicDropdownContent extends Component<BasicDropdownContent
205204 ) ;
206205 }
207206
208- window . addEventListener ( 'resize' , this . runloopAwareRepositionBound ) ;
209- window . addEventListener (
210- 'orientationchange' ,
211- this . runloopAwareRepositionBound ,
212- ) ;
207+ window . addEventListener ( 'resize' , this . repositionBound ) ;
208+ window . addEventListener ( 'orientationchange' , this . repositionBound ) ;
213209
214210 if ( this . isTouchDevice ) {
215211 document . addEventListener (
@@ -350,7 +346,7 @@ export default class BasicDropdownContent extends Component<BasicDropdownContent
350346 }
351347
352348 if ( shouldReposition ) {
353- this . runloopAwareReposition ( ) ;
349+ this . reposition ( ) ;
354350 }
355351 } ) ;
356352 this . mutationObserver . observe ( dropdownElement , {
@@ -405,31 +401,22 @@ export default class BasicDropdownContent extends Component<BasicDropdownContent
405401 }
406402
407403 @action
408- runloopAwareReposition ( ) : void {
404+ reposition ( ) : void {
409405 if ( ! this . args . dropdown ) {
410406 return ;
411407 }
412408
413- runTask ( this , ( ) => {
414- if ( ! this . args . dropdown ) {
415- return ;
416- }
417-
418- this . args . dropdown . actions . reposition ( ) ;
419- } ) ;
409+ this . args . dropdown . actions . reposition ( ) ;
420410 }
421411
422412 @action
423413 removeGlobalEvents ( ) : void {
424- window . removeEventListener ( 'resize' , this . runloopAwareRepositionBound ) ;
425- window . removeEventListener (
426- 'orientationchange' ,
427- this . runloopAwareRepositionBound ,
428- ) ;
414+ window . removeEventListener ( 'resize' , this . repositionBound ) ;
415+ window . removeEventListener ( 'orientationchange' , this . repositionBound ) ;
429416 }
430417
431418 touchMoveHandlerBound = ( e : TouchEvent ) => this . touchMoveHandler ( e ) ;
432- runloopAwareRepositionBound = ( ) => this . runloopAwareReposition ( ) ;
419+ repositionBound = ( ) => this . reposition ( ) ;
433420 touchStartHandlerBound = ( ) => this . touchStartHandler ( ) ;
434421
435422 // Methods
@@ -522,15 +509,15 @@ export default class BasicDropdownContent extends Component<BasicDropdownContent
522509 // These two functions wire up scroll handling if `preventScroll` is false.
523510 // These trigger reposition of the dropdown.
524511 addScrollEvents ( ) : void {
525- window . addEventListener ( 'scroll' , this . runloopAwareRepositionBound ) ;
512+ window . addEventListener ( 'scroll' , this . repositionBound ) ;
526513 this . scrollableAncestors . forEach ( ( el ) => {
527- el . addEventListener ( 'scroll' , this . runloopAwareRepositionBound ) ;
514+ el . addEventListener ( 'scroll' , this . repositionBound ) ;
528515 } ) ;
529516 }
530517 removeScrollEvents ( ) : void {
531- window . removeEventListener ( 'scroll' , this . runloopAwareRepositionBound ) ;
518+ window . removeEventListener ( 'scroll' , this . repositionBound ) ;
532519 this . scrollableAncestors . forEach ( ( el ) => {
533- el . removeEventListener ( 'scroll' , this . runloopAwareRepositionBound ) ;
520+ el . removeEventListener ( 'scroll' , this . repositionBound ) ;
534521 } ) ;
535522 }
536523}
0 commit comments