From 30e0309aa90f5527f0149d63e4167faf4287735d Mon Sep 17 00:00:00 2001 From: Brodie Davis Date: Tue, 17 Dec 2024 18:58:42 -0500 Subject: [PATCH] closes #2 use elementChild over first/last child --- src/lib/infiniteScroll/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/infiniteScroll/index.ts b/src/lib/infiniteScroll/index.ts index 5b808bd..764c15e 100644 --- a/src/lib/infiniteScroll/index.ts +++ b/src/lib/infiniteScroll/index.ts @@ -4,12 +4,12 @@ type loadFnType = () => void; export function infiniteScroll(node: HTMLElement, loadFn: loadFnType) { - let offsetHeight = (node.firstChild?.offsetHeight) / 2; + let offsetHeight = (node.firstElementChild?.offsetHeight) / 2; let nodeRect = node.getBoundingClientRect(); let nodeTop = nodeRect.top + offsetHeight; const watchScrolling = () => { - let lastChild = node.lastChild; + let lastChild = node.lastElementChild; let rect = lastChild?.getBoundingClientRect(); if ((rect.bottom - nodeTop) <= (node.offsetHeight)) { loadFn();