maxs15 / react-native-modalbox

A <Modal/> component for react-native
MIT License
2.9k stars 505 forks source link

When I use coverScreen=true, shut off the modal screen will flicker at the top #239

Open MackJac opened 6 years ago

MackJac commented 6 years ago

"react-native-modalbox": "^1.6.0" "react": "16.3.1", "react-native": "0.55.4",

congdoan1 commented 6 years ago

I also got this error

meiqi1992 commented 6 years ago

same issue! how to resolved?

nes123 commented 6 years ago

same issue with IOS only

nes123 commented 6 years ago

As a work around, do the following change in the index.js:

useNativeDriver: true => useNativeDriver: false

I hope it helps

colinluond commented 6 years ago

same issue. any chance to be resolved without a work around?

MackJac commented 6 years ago

@nes123 thankyou,it's works,but the animation is not running well. hope to have a best solution

herarya commented 6 years ago

same issue +1

loveninteb commented 6 years ago

same issue +1

ldhios commented 6 years ago

same issue +1

claudioviola commented 6 years ago

same issue +1

iOS react-native-cli: 2.0.1 react-native: 0.55.4 react-native-modalbox: 1.6.0

Uploaded a screencast here. flickering_modal.zip

UPDATE: On Android Real Device 8.0.0 works. no flickering occurred On iOS Real Device 11.4.1 works too

jayhack commented 6 years ago

Hey all,

setting useNativeDriver: false in index.js solved this for us. I've forked the repo and you can install from here:

~$: npm install git+ssh://github.com/jayhack/react-native-modalbox

Cheers! 🍻

nelson-glauber commented 6 years ago

@jayhack solution worked for me. thanks! you saved my day. @maxs15 do you have any plans to merge this change?

noahtallen commented 6 years ago

A similar issue on another modal package: https://github.com/react-native-community/react-native-modal/issues/92

I don't think useNativeDriver: false is a long term solution due to performance (which is already poor on low-powered android devices). I think it might ultimately be a react-native issue, though.

msqar commented 5 years ago

A similar issue on another modal package: react-native-community/react-native-modal#92

I don't think useNativeDriver: false is a long term solution due to performance (which is already poor on low-powered android devices). I think it might ultimately be a react-native issue, though.

You think setting that is not okay? What should we do then? :/ i hate having that flickering, is super annoying.

msqar commented 5 years ago

Seems that this is a react-native issue... in the react-native-modal github, they sent a fix for this. What should we do on modalbox? any idea guys?

nes123 commented 4 years ago

this should be the fix:


import React from 'react'; import PropTypes from 'prop-types'; import { View, StyleSheet, PanResponder, Animated, TouchableWithoutFeedback, Dimensions, Easing, BackHandler, Platform, Modal, Keyboard } from 'react-native';

const {height: SCREEN_HEIGHT, width: SCREEN_WIDTH} = Dimensions.get('window'); const styles = StyleSheet.create({ wrapper: { backgroundColor: 'white' }, transparent: { zIndex: 2, backgroundColor: 'rgba(0,0,0,0)' }, absolute: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0 } });

export default class ModalBox extends React.PureComponent { static propTypes = { isOpen: PropTypes.bool, isDisabled: PropTypes.bool, startOpen: PropTypes.bool, backdropPressToClose: PropTypes.bool, swipeToClose: PropTypes.bool, swipeThreshold: PropTypes.number, swipeArea: PropTypes.number, position: PropTypes.string, entry: PropTypes.string, backdrop: PropTypes.bool, backdropOpacity: PropTypes.number, backdropColor: PropTypes.string, backdropContent: PropTypes.element, animationDuration: PropTypes.number, backButtonClose: PropTypes.bool, easing: PropTypes.func, coverScreen: PropTypes.bool, keyboardTopOffset: PropTypes.number, onClosed: PropTypes.func, onOpened: PropTypes.func, onClosingState: PropTypes.func };

static defaultProps = { startOpen: false, backdropPressToClose: true, swipeToClose: true, swipeThreshold: 50, position: 'center', backdrop: true, backdropOpacity: 0.5, backdropColor: 'black', backdropContent: null, animationDuration: 400, backButtonClose: false, easing: Easing.elastic(0.8), coverScreen: false, keyboardTopOffset: Platform.OS == 'ios' ? 22 : 0, useNativeDriver: true };

constructor(props) { super(props);

this.onBackPress = this.onBackPress.bind(this);
this.handleOpenning = this.handleOpenning.bind(this);
this.onKeyboardHide = this.onKeyboardHide.bind(this);
this.onKeyboardChange = this.onKeyboardChange.bind(this);
this.animateBackdropOpen = this.animateBackdropOpen.bind(this);
this.animateBackdropClose = this.animateBackdropClose.bind(this);
this.stopAnimateOpen = this.stopAnimateOpen.bind(this);
this.animateOpen = this.animateOpen.bind(this);
this.stopAnimateClose = this.stopAnimateClose.bind(this);
this.animateClose = this.animateClose.bind(this);
this.calculateModalPosition = this.calculateModalPosition.bind(this);
this.createPanResponder = this.createPanResponder.bind(this);
this.onViewLayout = this.onViewLayout.bind(this);
this.onContainerLayout = this.onContainerLayout.bind(this);
this.renderBackdrop = this.renderBackdrop.bind(this);
this.renderContent = this.renderContent.bind(this);
this.open = this.open.bind(this);
this.close = this.close.bind(this);

const position = props.startOpen
  ? new Animated.Value(0)
  : new Animated.Value(
      props.entry === 'top' ? -SCREEN_HEIGHT : SCREEN_HEIGHT
    );
this.state = {
  position,
  backdropOpacity: new Animated.Value(0),
  isOpen: props.startOpen,
  isAnimateClose: false,
  isAnimateOpen: false,
  swipeToClose: false,
  height: SCREEN_HEIGHT,
  width: SCREEN_WIDTH,
  containerHeight: SCREEN_HEIGHT,
  containerWidth: SCREEN_WIDTH,
  isInitialized: false,
  keyboardOffset: 0,
  pan: this.createPanResponder(position),
  hideContent: false,
};

// Needed for iOS because the keyboard covers the screen
if (Platform.OS === 'ios') {
  this.subscriptions = [
    Keyboard.addListener('keyboardWillChangeFrame', this.onKeyboardChange),
    Keyboard.addListener('keyboardDidHide', this.onKeyboardHide)
  ];
}

}

componentDidMount() { this.handleOpenning(); }

componentDidUpdate(prevProps) { if (this.props.isOpen != prevProps.isOpen) { this.handleOpenning(); } }

componentWillUnmount() { if (this.subscriptions) this.subscriptions.forEach(sub => sub.remove()); if (this.props.backButtonClose && Platform.OS === 'android') BackHandler.removeEventListener('hardwareBackPress', this.onBackPress); }

onBackPress() { this.close(); return true; }

handleOpenning() { if (typeof this.props.isOpen == 'undefined') return; if (this.props.isOpen) this.open(); else this.close(); }

/** ANIMATIONS **/

/*


Dylan0916 commented 4 years ago

Same issue. any updates?

khoatran808 commented 4 years ago

Same issue

"react": "16.13.1", "react-native": "0.62.0", "react-native-modalbox": "2.0.0",

mehmetnyarar commented 3 years ago

@nes123 why not creating a PR instead?