I'm using this library: https://github.com/wix/react-native-interactable to create an interactable view.
Here's an example of a working use case:
import { Component }, React from 'react';
import { View } from 'react-native';
import Interactable from 'react-native-interactable';
class MainScreen extends Component {
onDrag() {
console.log("dragging...")
}
onSnap() {
console.log("snapped!")
}
render() {
return(
<View>
<Interactable.View
style={{backgroundColor: '#000000', width: 100, height: 100}}
horizontalOnly={true}
snapPoints={[{x: 0}, {x: 200}]}
onDrag={ () => this.onDrag() }
onSnap={ () => this.onSnap() }>
</Interactable.View>
</View>
)
}
}
However, because I wanted to get the event object in the call (as mentioned here), I'm unable to implement it correctly. For some reason, the onDrag and onSnap functions aren't getting called. Here's my implementation of binding functions (that isn't working correctly):
import { Component }, React from 'react';
import { View } from 'react-native';
import Interactable from 'react-native-interactable';
class MainScreen extends Component {
onDrag(event) {
console.log("dragging...", event)
}
onSnap(event) {
console.log("snapped!", event)
}
render() {
return(
<View>
<Interactable.View
style={{backgroundColor: '#000000', width: 100, height: 100}}
horizontalOnly={true}
snapPoints={[{x: 0}, {x: 200}]}
onDrag={ this.onDrag.bind(this) }
onSnap={ this.onSnap.bind(this) }>
</Interactable.View>
</View>
)
}
}
Anyone has any idea what am I missing out on? I also tried binding the functions within the constructor, but it didn't seem to work.