React-native-reanimated: SnapTo works only on double click

Created on 12 Nov 2019  路  6Comments  路  Source: software-mansion/react-native-reanimated

Issue:

I am using the Notification Panel example for one of my projects. I am trying to snap the panel to the initial state when we click on the close button. This works when I double click the button but the single click is not triggering the action.

Code:

...other code
export default class App extends Component {
notif = React.createRef()
render() {
    return (
      <View style={styles.container}>
...other code
        <Interactable.View
            ref={this.notif}
            verticalOnly={true}
            snapPoints={[
              { y: 0, tension: 0, damping: 1 },
              { y: -Screen.height + 80 },
            ]}>
...other code
            <Button title="Close" onPress={() => this.notif.current.snapTo({index: 1})} ></Button>
       </Interactable.View>
     }
}
...other code

snap
FYI-- I was doing double click during the last few seconds where the panel goes to correct snap.

Let me know if I am doing something wrong.

Most helpful comment

@cedricsandars My fix was not the right fix, it just make the clock run all the time.

I found the right fix:
https://github.com/software-mansion/react-native-reanimated/issues/182#issuecomment-519632308

All 6 comments

I experience the same issue on the initial rendering of the panel only.

Step to reproduce

  • Set verticalOnly={true}
  • The first button click nothing happens
  • The second button click it opens

I managed to fix it by removing the verticalOnly={true} property but now the panel can move on the x axis as well.

I hardcoded this:
image

Nevermind the real fix is this:
image

if you were using verticalOnly of horizontalOnly you would experience the multiple click needed on first render.

@wilau2 - The fix worked. Thanks a lot!!

@cedricsandars My fix was not the right fix, it just make the clock run all the time.

I found the right fix:
https://github.com/software-mansion/react-native-reanimated/issues/182#issuecomment-519632308

@wilau2 - Thanks for helping again. Love the way how open source community works to help others even without even expecting anything in return :)

Was this page helpful?
0 / 5 - 0 ratings