Skip to content

Commit 8375c18

Browse files
author
Elson Correia
committed
check for span element
1 parent 8a08d29 commit 8375c18

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/___subComponents/ScrollRenderer.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ const ScrollRenderer = (props: Props) => {
2929

3030
const onScroll = (span: any) => () => {
3131
requestAnimationFrame(() => {
32-
const startingPoint = span.parentNode.offsetTop + span.parentNode.offsetHeight;
33-
const anchorPos = span.offsetTop - span.parentNode.scrollTop;
32+
if (span) {
33+
const startingPoint = span.parentNode.offsetTop + span.parentNode.offsetHeight;
34+
const anchorPos = span.offsetTop - span.parentNode.scrollTop;
3435

35-
if (anchorPos <= (startingPoint + (span.parentNode.offsetHeight * 2))) {
36-
updateRenderInfo();
36+
if (anchorPos <= (startingPoint + (span.parentNode.offsetHeight * 2))) {
37+
updateRenderInfo();
38+
}
3739
}
3840
});
3941
};
@@ -58,7 +60,7 @@ const ScrollRenderer = (props: Props) => {
5860
});
5961

6062
requestAnimationFrame(() => {
61-
if (span.parentNode) {
63+
if (span && span.parentNode) {
6264
span.parentNode.scrollTop = pos;
6365
}
6466
});

0 commit comments

Comments
 (0)