Skip to content

Commit

Permalink
check for span element
Browse files Browse the repository at this point in the history
  • Loading branch information
ECorreia45 committed Jan 2, 2021
1 parent 8a08d29 commit 8375c18
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/___subComponents/ScrollRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ const ScrollRenderer = (props: Props) => {

const onScroll = (span: any) => () => {
requestAnimationFrame(() => {
const startingPoint = span.parentNode.offsetTop + span.parentNode.offsetHeight;
const anchorPos = span.offsetTop - span.parentNode.scrollTop;
if (span) {
const startingPoint = span.parentNode.offsetTop + span.parentNode.offsetHeight;
const anchorPos = span.offsetTop - span.parentNode.scrollTop;

if (anchorPos <= (startingPoint + (span.parentNode.offsetHeight * 2))) {
updateRenderInfo();
if (anchorPos <= (startingPoint + (span.parentNode.offsetHeight * 2))) {
updateRenderInfo();
}
}
});
};
Expand All @@ -58,7 +60,7 @@ const ScrollRenderer = (props: Props) => {
});

requestAnimationFrame(() => {
if (span.parentNode) {
if (span && span.parentNode) {
span.parentNode.scrollTop = pos;
}
});
Expand Down

0 comments on commit 8375c18

Please sign in to comment.