From afebf6c2ade50cbc66ad2fd82229be9c348c76ab Mon Sep 17 00:00:00 2001 From: Andrew Kirwin Date: Thu, 16 May 2024 12:25:08 +0100 Subject: [PATCH] add mutation observer to get failing test to pass --- addon/components/infinite-scroller.gjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addon/components/infinite-scroller.gjs b/addon/components/infinite-scroller.gjs index 8649fa2..05594fb 100644 --- a/addon/components/infinite-scroller.gjs +++ b/addon/components/infinite-scroller.gjs @@ -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(); } @@ -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() {