Adrià Vilanova Martínez | fe69478 | 2024-11-09 20:40:43 +0100 | [diff] [blame] | 1 | import { NodeMutation } from '../../../../presentation/nodeWatcher/NodeWatcherHandler'; |
| 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 | } |