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

Use spring animation on iOS #728

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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