Skip to content
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
12 changes: 7 additions & 5 deletions LightboxOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ export default class LightboxOverlay extends Component {
renderHeader: PropTypes.func,
onOpen: PropTypes.func,
onClose: PropTypes.func,
willClose: PropTypes.func,
willClose: PropTypes.func,
swipeToDismiss: PropTypes.bool,
useNativeDriver: PropTypes.bool,
};

static defaultProps = {
springConfig: { tension: 30, friction: 7 },
backgroundColor: 'black',
useNativeDriver: false,
};

constructor(props) {
Expand Down Expand Up @@ -99,7 +101,7 @@ export default class LightboxOverlay extends Component {
onPanResponderMove: Animated.event([
null,
{ dy: this.state.pan }
]),
], { useNativeDriver: props.useNativeDriver }),
onPanResponderTerminationRequest: (evt, gestureState) => true,
onPanResponderRelease: (evt, gestureState) => {
if(Math.abs(gestureState.dy) > DRAG_DISMISS_THRESHOLD) {
Expand All @@ -115,7 +117,7 @@ export default class LightboxOverlay extends Component {
} else {
Animated.spring(
this.state.pan,
{ toValue: 0, ...this.props.springConfig }
{ toValue: 0, useNativeDriver: props.useNativeDriver, ...this.props.springConfig }
).start(() => { this.setState({ isPanning: false }); });
}
},
Expand Down Expand Up @@ -144,7 +146,7 @@ export default class LightboxOverlay extends Component {

Animated.spring(
this.state.openVal,
{ toValue: 1, ...this.props.springConfig }
{ toValue: 1, useNativeDriver: this.props.useNativeDriver, ...this.props.springConfig }
).start(() => {
this.setState({ isAnimating: false });
this.props.didOpen();
Expand All @@ -161,7 +163,7 @@ export default class LightboxOverlay extends Component {
});
Animated.spring(
this.state.openVal,
{ toValue: 0, ...this.props.springConfig }
{ toValue: 0, useNativeDriver: this.props.useNativeDriver, ...this.props.springConfig }
).start(() => {
this.setState({
isAnimating: false,
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const MyApp = () => (
|**`backgroundColor`**|`string`|Color of lightbox background, defaults to `black`|
|**`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 }`.|
|**`useNativeDriver`**|`bool`|Set the useNativeDriver option for all animations (defaults to false)|

## Demo

Expand Down