Adrià Vilanova Martínez | 43c7520 | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 1 | import { NodeMutation } from '../../../presentation/nodeWatcher/NodeWatcherHandler'; |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 2 | import CssSelectorNodeWatcherHandler from '../../../infrastructure/presentation/nodeWatcher/handlers/CssSelectorHandler.adapter'; |
| 3 | import CCInfiniteScroll from '../core/ccInfiniteScroll'; |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 4 | |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 5 | export default class CCInfiniteScrollSetUpHandler extends CssSelectorNodeWatcherHandler { |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 6 | cssSelector = 'ec-app, .scrollable-content'; |
| 7 | |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 8 | constructor(private ccInfiniteScroll: CCInfiniteScroll) { |
| 9 | super(); |
| 10 | } |
| 11 | |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 12 | onMutatedNode({ node }: NodeMutation) { |
| 13 | if (!(node instanceof Element)) return; |
| 14 | const isScrollableContent = node.classList.contains('scrollable-content'); |
Adrià Vilanova Martínez | 7c941c7 | 2024-10-26 20:23:34 +0200 | [diff] [blame] | 15 | this.ccInfiniteScroll.setUpIntersectionObserver(node, isScrollableContent); |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 16 | } |
| 17 | } |