I'm making a React-Native app and the scenario is this: I want the user to be able to pan a view, but not wholly the way he wants. I'd like to constraint how much the view can move when being dragged by the user.
I've read through the documentation of both the PanResponder
and Animated
API (multiple times), but can't find anything that does this, neither can I find anyone else that implemented something alike.
Constraining in the panresponder's event?
onPanResponderMove: Animated.event([null,{
dx: this.state.pan.x, //Some function here to constrain the value?
dy: this.state.pan.y
}]),
Constraining while applying the transforms?
style = {
transform: {
transformX: ...,//Use interpolate to constrain the values somehow?
transformY: ...
}
}