Skip to content

Commit 09c442a

Browse files
Merge pull request #89 from thisispaul/master
2 parents b5a0597 + 2504ade commit 09c442a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Scrollama.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ const Scrollama = props => {
4343
}
4444
}, []);
4545

46-
const innerHeight = (windowInnerHeight || window.innerHeight)
46+
const isBrowser = typeof window !== "undefined";
47+
const innerHeight = isBrowser ? (windowInnerHeight || window.innerHeight) : 0;
4748

48-
const offsetValue = isOffsetDefinedInPixels
49+
const offsetValue = isOffsetDefinedInPixels
4950
? (+offset.replace('px', '') / innerHeight)
5051
: offset;
5152

src/Step.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const Step = props => {
2727
innerHeight,
2828
} = props;
2929

30-
const scrollTop = document.documentElement.scrollTop;
30+
const isBrowser = typeof window !== "undefined";
31+
const scrollTop = isBrowser ? document.documentElement.scrollTop : 0;
3132
const direction = lastScrollTop < scrollTop ? 'down' : 'up';
3233

3334
const rootMargin = useRootMargin(offset);
@@ -58,7 +59,7 @@ const Step = props => {
5859
},
5960
[inViewRef, scrollProgressRef],
6061
);
61-
62+
6263

6364
React.useEffect(() => {
6465
if (isIntersecting) {

0 commit comments

Comments
 (0)