Infinite Scroll: Attempt to fix a weird bug with missing chats

This commit is contained in:
Alexander Zinchuk 2021-04-30 01:31:50 +03:00
parent 0bc2d2b021
commit a49b02e291

View File

@ -140,7 +140,7 @@ const InfiniteScroll: FC<OwnProps> = ({
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<OwnProps> = ({
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<OwnProps> = ({
}
if (!isUpdated) {
if (currentAnchor) {
if (currentAnchor && currentAnchor.offsetParent) {
stateRef.current.currentAnchorTop = currentAnchor.getBoundingClientRect().top;
} else {
const nextAnchor = listItemElements[0];