Skip to content

Commit

Permalink
Merge pull request #40 from bramschulting/master
Browse files Browse the repository at this point in the history
Mark partially visible when center is visible
  • Loading branch information
joshwnj authored Jul 20, 2016
2 parents 8d77951 + 3a44951 commit 3bd1a0f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions visibility-sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ module.exports = React.createClass({
// check for partial visibility
if (this.props.partialVisibility) {
var partialVertical =
(rect.top >= containmentRect.top && rect.top <= containmentRect.bottom)
|| (rect.bottom >= containmentRect.top && rect.bottom <= containmentRect.bottom)
|| (rect.top <= containmentRect.top && rect.bottom >= containmentRect.bottom);
(rect.top >= containmentRect.top && rect.top <= containmentRect.bottom) // Top is visible
|| (rect.bottom >= containmentRect.top && rect.bottom <= containmentRect.bottom) // Bottom is visible
|| (rect.top <= containmentRect.top && rect.bottom >= containmentRect.bottom); // Center is visible


var partialHorizontal =
(rect.left >= containmentRect.left && rect.left <= containmentRect.right)
|| (rect.right >= containmentRect.left && rect.right <= containmentRect.right);
(rect.left >= containmentRect.left && rect.left <= containmentRect.right) // Left side is visible
|| (rect.right >= containmentRect.left && rect.right <= containmentRect.right) // Right side is visible
|| (rect.left <= containmentRect.left && rect.right >= containmentRect.right); // Center is visible

var partialVisible = partialVertical && partialHorizontal;

Expand Down

0 comments on commit 3bd1a0f

Please sign in to comment.