diff --git a/src/resolveScrollableAncestorProp.js b/src/resolveScrollableAncestorProp.js index fa343ab..f589c29 100644 --- a/src/resolveScrollableAncestorProp.js +++ b/src/resolveScrollableAncestorProp.js @@ -2,8 +2,13 @@ export default function resolveScrollableAncestorProp(scrollableAncestor) { // When Waypoint is rendered on the server, `window` is not available. // To make Waypoint easier to work with, we allow this to be specified in // string form and safely convert to `window` here. + const globalWindow = + typeof window !== 'undefined' ? window : + typeof global !== 'undefined' && global.window ? global.window : + undefined; + if (scrollableAncestor === 'window') { - return global.window; + return globalWindow; } return scrollableAncestor;