diff --git a/dist/inview.js b/dist/inview.js index 1bc4165..5614dbb 100644 --- a/dist/inview.js +++ b/dist/inview.js @@ -49,7 +49,6 @@ function getBoundingBox(el) { } // Checks to see if element is visisble - function isElementFullyVisible(el, rect, viewport) { return rect.top >= viewport.top && rect.left >= 0 && rect.bottom <= viewport.top + viewport.height && rect.right <= (window.innerWidth || document.documentElement.clientWidth); } @@ -110,6 +109,10 @@ var ReactInviewWrapper = function ReactInviewWrapper() { }, { key: 'handleScroll', value: function handleScroll() { + if (typeof this.refs.container === 'undefined') { + return; + } + var element = this.refs.container.children[0]; var boundingBox = getBoundingBox(element); var viewPortBox = getViewPortBox(offsetY, boundingBox); diff --git a/package.json b/package.json index 2d12515..0d14c89 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Benton Rochester", "name": "react-inview-js", - "version": "1.2.6", + "version": "1.2.7", "description": "React Inview checker with only javascript", "main": "dist/index.js", "standard": { diff --git a/src/inview.jsx b/src/inview.jsx index c3b0aef..e543c2e 100644 --- a/src/inview.jsx +++ b/src/inview.jsx @@ -29,7 +29,6 @@ function getBoundingBox(el) { } // Checks to see if element is visisble - function isElementFullyVisible (el, rect, viewport) { return ( rect.top >= viewport.top && @@ -39,7 +38,6 @@ function isElementFullyVisible (el, rect, viewport) { ); } - function isElementTopVisible (el, rect, viewport) { const topIsInView = !(rect.top >= (viewport.top + viewport.height)); const topIsAboveView = !((rect.top + rect.height - viewport.height) <= viewport.top); @@ -87,6 +85,8 @@ let ReactInviewWrapper = function ReactInviewWrapper ({ } handleScroll() { + if (typeof this.refs.container === 'undefined') { return; } + const element = this.refs.container.children[0]; const boundingBox = getBoundingBox(element); const viewPortBox = getViewPortBox(offsetY, boundingBox);