Skip to content
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ const styles = StyleSheet.create({
| onRequestClose | func | undefined | Callback invoked when the hardware back button on Android or the menu button on Apple TV is pressed |
| keyboardVerticalOffset | number | undefined | keyboardVerticalOffset for iOS |
| verticalButtons | bool | false | Renders button vertically |
| useNativeDriver | bool | false | Defines if animations should use native driver |

### Dialog.Input props

Expand Down
2 changes: 2 additions & 0 deletions src/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type DialogContainerProps = PropsWithChildren<{
onBackdropPress?: () => void;
onRequestClose?: () => void;
keyboardVerticalOffset?: number;
useNativeDriver?: boolean;
}>;

const DialogContainer: React.FC<DialogContainerProps> = (props) => {
Expand Down Expand Up @@ -146,6 +147,7 @@ DialogContainer.propTypes = {
verticalButtons: PropTypes.bool,
onBackdropPress: PropTypes.func,
keyboardVerticalOffset: PropTypes.number,
useNativeDriver: PropTypes.bool,
children: PropTypes.node.isRequired,
};

Expand Down
9 changes: 5 additions & 4 deletions src/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export interface ModalProps extends ReactNativeModalProps {
onHide?: () => void;
visible?: boolean;
contentStyle?: StyleProp<ViewStyle>;
useNativeDriver?: boolean;
}

interface ModalState {
Expand All @@ -77,12 +78,14 @@ export class Modal extends Component<ModalProps, ModalState> {
onHide: PropTypes.func,
visible: PropTypes.bool,
contentStyle: ViewPropTypes.style,
useNativeDriver: PropTypes.bool,
};

static defaultProps: Partial<ModalProps> = {
onBackdropPress: () => null,
onHide: () => null,
visible: false,
useNativeDriver: false,
};

state: ModalState = {
Expand Down Expand Up @@ -116,8 +119,7 @@ export class Modal extends Component<ModalProps, ModalState> {
this.setState({ visible: true, currentAnimation: "in" }, () => {
Animated.timing(this.animVal, {
easing: Easing.inOut(Easing.quad),
// Using native driver in the modal makes the content flash
useNativeDriver: false,
useNativeDriver: Boolean(this.props.useNativeDriver),
duration: MODAL_ANIM_DURATION,
toValue: 1,
}).start(() => {
Expand All @@ -130,8 +132,7 @@ export class Modal extends Component<ModalProps, ModalState> {
this.setState({ currentAnimation: "out" }, () => {
Animated.timing(this.animVal, {
easing: Easing.inOut(Easing.quad),
// Using native driver in the modal makes the content flash
useNativeDriver: false,
useNativeDriver: Boolean(this.props.useNativeDriver),
duration: MODAL_ANIM_DURATION,
toValue: 0,
}).start(() => {
Expand Down