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

Add backgroundPosition props #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion Lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class Lightbox extends Component {
renderContent: PropTypes.func,
underlayColor: PropTypes.string,
backgroundColor: PropTypes.string,
backgroundPosition: PropTypes.string,
didOpen: PropTypes.func,
onOpen: PropTypes.func,
willClose: PropTypes.func,
Expand Down Expand Up @@ -60,11 +61,12 @@ export default class Lightbox extends Component {
swipeToDismiss: this.props.swipeToDismiss,
springConfig: this.props.springConfig,
backgroundColor: this.props.backgroundColor,
backgroundPosition: this.props.backgroundPosition,
children: this.getContent(),
didOpen: this.props.didOpen,
willClose: this.props.willClose,
onClose: this.onClose,
})
});

open = () => {
this._root.measure((ox, oy, width, height, px, py) => {
Expand Down
8 changes: 6 additions & 2 deletions LightboxOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ export default class LightboxOverlay extends Component {
friction: PropTypes.number,
}),
backgroundColor: PropTypes.string,
backgroundPosition: PropTypes.string,
isOpen: PropTypes.bool,
renderHeader: PropTypes.func,
onOpen: PropTypes.func,
onClose: PropTypes.func,
willClose: PropTypes.func,
swipeToDismiss: PropTypes.bool,
};
};

static defaultProps = {
springConfig: { tension: 30, friction: 7 },
Expand Down Expand Up @@ -183,6 +184,7 @@ export default class LightboxOverlay extends Component {
swipeToDismiss,
origin,
backgroundColor,
backgroundPosition,
} = this.props;

const {
Expand All @@ -209,7 +211,9 @@ export default class LightboxOverlay extends Component {
lightboxOpacityStyle.opacity = this.state.pan.interpolate({inputRange: [-WINDOW_HEIGHT, 0, WINDOW_HEIGHT], outputRange: [0, 1, 0]});
}

const openStyle = [styles.open, {
const openStyle = [styles.open,
backgroundPosition && { justifyContent: backgroundPosition },
{
left: openVal.interpolate({inputRange: [0, 1], outputRange: [origin.x, target.x]}),
top: openVal.interpolate({inputRange: [0, 1], outputRange: [origin.y + STATUS_BAR_OFFSET, target.y + STATUS_BAR_OFFSET]}),
width: openVal.interpolate({inputRange: [0, 1], outputRange: [origin.width, WINDOW_WIDTH]}),
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const MyApp = () => (
|**`didOpen`**|`function`|Triggered after lightbox is opened|
|**`underlayColor`**|`string`|Color of touchable background, defaults to `black`|
|**`backgroundColor`**|`string`|Color of lightbox background, defaults to `black`|
|**`backgroundPosition`**|`string`|Position of lightbox background, defaults to `center`. Value of [justifyContent](https://facebook.github.io/react-native/docs/flexbox#justify-content).|
|**`swipeToDismiss`**|`bool`|Enables gestures to dismiss the fullscreen mode by swiping up or down, defaults to `true`.|
|**`springConfig`**|`object`|[`Animated.spring`](https://facebook.github.io/react-native/docs/animations.html) configuration, defaults to `{ tension: 30, friction: 7 }`.|

Expand Down