Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for string partialVisibility values - so it detecs chan… #42

Merged
merged 1 commit into from
Aug 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions visibility-sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ module.exports = React.createClass({
propTypes: {
onChange: React.PropTypes.func.isRequired,
active: React.PropTypes.bool,
partialVisibility: React.PropTypes.bool,
partialVisibility: React.PropTypes.oneOfType([
React.PropTypes.bool,
React.PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
]),
delay: React.PropTypes.number,
containment: containmentPropType,
children: React.PropTypes.element
Expand Down Expand Up @@ -111,7 +114,7 @@ module.exports = React.createClass({
var partialVisible = partialVertical && partialHorizontal;

var isVisible = this.props.partialVisibility
? partialVisible
? (typeof partialVisible === 'string' ? visibilityRect[partialVisible] : partialVisible)
: fullVisible;

var state = this.state
Expand Down