Skip to content

Commit

Permalink
Merge pull request #1 from Zeikko/master
Browse files Browse the repository at this point in the history
Set inViewport to false when element is no longer in viewport
  • Loading branch information
roderickhsiao authored Nov 30, 2017
2 parents eeaa4f1 + adc6598 commit e23bf65
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ function handleViewport(Component, options) {
const entry = entries[0] || {};
const { intersectionRatio } = entry;
if (intersectionRatio <= 0) {
return;
this.setState({
inViewport: false
});
} else {
this.setState({
inViewport: true
});
}
this.setState({
inViewport: true
});
}

render() {
Expand Down

0 comments on commit e23bf65

Please sign in to comment.