React-native-interactable: Programmatically changing the position

Created on 26 Apr 2017  路  4Comments  路  Source: wix/react-native-interactable

I tried to do it, but changing initialPosition has no effect. How can this be done? Can the position be animated? This is important for many applications.
Thanks!

Most helpful comment

Hi guys, I tried to call snapTo method in "ComponentDidMount" eg. this.refs['menuInstance'].snapTo({index: index}), but it does not trigger the snap. I was wondering if this is even possible to do? Thanks!

All 4 comments

You can use imperative SnapTo method (take a look on issue #44)

Hi guys, I tried to call snapTo method in "ComponentDidMount" eg. this.refs['menuInstance'].snapTo({index: index}), but it does not trigger the snap. I was wondering if this is even possible to do? Thanks!

@Blackmamba23 having the same problem. seems like Intractable.View methods are not called in componentDidMount.
At some cases, they are not even called in componentDidUpdate either.
I'm still investigating the bug, not sure if it's supposed to be like this or it's a bug.
Try to make your changes on onLayout

<Intractable.View 
       onLayout = {() => this.handleAnimation() }
       ref = {ref => this.animatedViewRef = ref}
        .....
</Intractable.View>

handleAnimation() {
     this.animatedViewRef.snapTo({index:1})
}

Thank you @kevinNejad

Was this page helpful?
0 / 5 - 0 ratings