maxs15 / maxs15/react-native-modalbox

Set useNativeDriver to false, and the centered popup will shift to the right after the animation ends

Open
#366 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.9k
Forks
496
PR merge metrics
No merged PRs in 30d

Description

  1. The width and height of modalBox are set to 300
  2. Pop up box modalBox setting centered
  3. Set useNativeDriver to false
  4. After the pop-up animation ends, the position shifts to the right

Reason for the problem: JS layer rendering calculates width and height, and non same thread may cause native animations to not update
Solution: Horizontal centering using alignSelf: 'center', modifying renderContent() can solve this type of problem

`renderContent() {
const size = {
height: this.state.containerHeight,
width: this.state.containerWidth
};
// const offsetX = (this.state.containerWidth - this.state.width) / 2;

return (
<Animated.View
onLayout={this.onViewLayout}
style={[
styles.wrapper,
size,
this.props.style,
{
alignSelf: 'center', //New addition
transform: [
{translateY: this.state.position}
// {translateX: offsetX}
]
}
]}
{...this.state.pan.panHandlers}>
{this.props.children}
</Animated.View>
);
}`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating renderContent() and inspect the Animated.View styling around the modalBox dimensions, centering, and useNativeDriver behavior. Reproduce the issue with a 300x300 modalBox and useNativeDriver set to false; done means the popup remains horizontally centered after the animation ends.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.