diff --git a/src/components/ui/InfiniteScroll.tsx b/src/components/ui/InfiniteScroll.tsx index d1cf6d006..fe2cff7de 100644 --- a/src/components/ui/InfiniteScroll.tsx +++ b/src/components/ui/InfiniteScroll.tsx @@ -140,7 +140,7 @@ const InfiniteScroll: FC = ({ const nextAnchor = listItemElements[0]; if (nextAnchor) { const nextAnchorTop = nextAnchor.getBoundingClientRect().top; - const newAnchorTop = currentAnchor && currentAnchor !== nextAnchor + const newAnchorTop = currentAnchor && currentAnchor.offsetParent && currentAnchor !== nextAnchor ? currentAnchor.getBoundingClientRect().top : nextAnchorTop; const isMovingUp = ( @@ -161,7 +161,7 @@ const InfiniteScroll: FC = ({ const nextAnchor = listItemElements[listLength - 1]; if (nextAnchor) { const nextAnchorTop = nextAnchor.getBoundingClientRect().top; - const newAnchorTop = currentAnchor && currentAnchor !== nextAnchor + const newAnchorTop = currentAnchor && currentAnchor.offsetParent && currentAnchor !== nextAnchor ? currentAnchor.getBoundingClientRect().top : nextAnchorTop; const isMovingDown = ( @@ -179,7 +179,7 @@ const InfiniteScroll: FC = ({ } if (!isUpdated) { - if (currentAnchor) { + if (currentAnchor && currentAnchor.offsetParent) { stateRef.current.currentAnchorTop = currentAnchor.getBoundingClientRect().top; } else { const nextAnchor = listItemElements[0];