Skip to content

Commit

Permalink
Use scrollingElement for clientHeight evaluation, if avaialble.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhefner committed Jan 5, 2018
1 parent 515e9fc commit 492eae1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class ScrollTrigger extends Component {
const element = ReactDOM.findDOMNode(this.element);
const elementRect = element.getBoundingClientRect();
const viewportStart = 0;
const viewportEnd = document.body.clientHeight;
const scrollingElement = document.scrollingElement || document.body;
const viewportEnd = scrollingElement.clientHeight;
const inViewport = elementRect.top < viewportEnd && elementRect.bottom > viewportStart;

const position = window.scrollY;
Expand Down

0 comments on commit 492eae1

Please sign in to comment.