Skip to content
Open
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
18 changes: 10 additions & 8 deletions src/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import {
Animated,
DeviceEventEmitter,
Dimensions,
Easing,
Modal as ReactNativeModal,
StyleSheet,
TouchableWithoutFeedback,
} from "react-native";

const MODAL_ANIM_DURATION = 300;
const MODAL_BACKDROP_OPACITY = 0.4;
const ANIMATION_CONFIG = {
damping: 500,
stiffness: 1000,
mass: 3,
overshootClamping: true,
};

export class Modal extends Component {
static propTypes = {
Expand Down Expand Up @@ -75,21 +79,19 @@ export class Modal extends Component {

show = () => {
this.setState({ isVisible: true });
Animated.timing(this.animVal, {
easing: Easing.inOut(Easing.quad),
Animated.spring(this.animVal, {
...ANIMATION_CONFIG,
// Using native driver in the modal makes the content flash
useNativeDriver: false,
duration: MODAL_ANIM_DURATION,
toValue: 1,
}).start();
};

hide = () => {
Animated.timing(this.animVal, {
easing: Easing.inOut(Easing.quad),
Animated.spring(this.animVal, {
...ANIMATION_CONFIG,
// Using native driver in the modal makes the content flash
useNativeDriver: false,
duration: MODAL_ANIM_DURATION,
toValue: 0,
}).start(() => {
if (this._isMounted) {
Expand Down