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();