blob: ad6e153076e72dd717a598b52c81608440945259 [file] [log] [blame]
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +01001import { NodeMutation } from '../../../../presentation/nodeWatcher/NodeWatcherHandler';
2import 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}