Skip to content

Commit

Permalink
add mutation observer to get failing test to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
amk221 committed May 16, 2024
1 parent 8ceebe4 commit afebf6c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions addon/components/infinite-scroller.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,11 @@ export default class InfiniteScrollerComponent extends Component {

resolve(this.args.onLoadMore?.(direction)).finally(() => {
this.isLoading = false;

this._checkScrollable();
});
}

_registerScroller(element) {
this.scroller = element;

this._startListening();
this._checkScrollable();
}
Expand All @@ -94,10 +91,13 @@ export default class InfiniteScrollerComponent extends Component {

_startListening() {
this.scroller.addEventListener('scroll', this.handleScroll);
this.observer = new MutationObserver(this._checkScrollable.bind(this));
this.observer.observe(this.scroller, { childList: true });
}

_stopListening() {
this.scroller.removeEventListener('scroll', this.handleScroll);
this.observer.disconnect();
}

_checkShouldLoadMore() {
Expand Down

0 comments on commit afebf6c

Please sign in to comment.