From 93270505ee60416b509b1824dad267eef716f349 Mon Sep 17 00:00:00 2001 From: nitaking <10850034+nitaking@users.noreply.github.com> Date: Sun, 24 Mar 2019 12:43:03 +0900 Subject: [PATCH 1/2] Add: backgroundPosition --- Lightbox.js | 4 +++- LightboxOverlay.js | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Lightbox.js b/Lightbox.js index 56c8536..ffa282a 100644 --- a/Lightbox.js +++ b/Lightbox.js @@ -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, @@ -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) => { diff --git a/LightboxOverlay.js b/LightboxOverlay.js index 7ed2243..499edb3 100644 --- a/LightboxOverlay.js +++ b/LightboxOverlay.js @@ -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 }, @@ -183,6 +184,7 @@ export default class LightboxOverlay extends Component { swipeToDismiss, origin, backgroundColor, + backgroundPosition, } = this.props; const { @@ -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]}), From 4bdc7e543e2d49faab4cad95030a85dd183616f1 Mon Sep 17 00:00:00 2001 From: nitaking <10850034+nitaking@users.noreply.github.com> Date: Sun, 24 Mar 2019 12:55:44 +0900 Subject: [PATCH 2/2] :memo: Add readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6bc4ffe..a916446 100644 --- a/README.md +++ b/README.md @@ -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 }`.|