blob: 0d77cf74bf019017c295f16b82781abda1a39d87 [file] [log] [blame]
Adrià Vilanova Martínez43c75202024-10-19 15:55:15 +02001import { NodeMutation } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +02002import CssSelectorNodeWatcherHandler from '../../../infrastructure/presentation/nodeWatcher/handlers/CssSelectorHandler.adapter';
3import CCInfiniteScroll from '../core/ccInfiniteScroll';
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02004
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +02005export default class CCInfiniteScrollSetUpHandler extends CssSelectorNodeWatcherHandler {
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02006 cssSelector = 'ec-app, .scrollable-content';
7
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +02008 constructor(private ccInfiniteScroll: CCInfiniteScroll) {
9 super();
10 }
11
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020012 onMutatedNode({ node }: NodeMutation) {
13 if (!(node instanceof Element)) return;
14 const isScrollableContent = node.classList.contains('scrollable-content');
Adrià Vilanova Martínez7c941c72024-10-26 20:23:34 +020015 this.ccInfiniteScroll.setUpIntersectionObserver(node, isScrollableContent);
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020016 }
17}