I have a drawer that hovers over a view. The user can vertically drag up to open and drag down to close it. I have the opening and closing part working smoothly. What I have a problem with is making sure that the drag animation stops once it reaches about 200 pixels from the top of the phone screen and also not drag beyond 100 pixels from the bottom of the screen. It's an absolute element and I have used Animated.ValueXY()
. I know that I need to stop animation in the onPanResponderMove: (e, gestureState) =>{}
function. I tried stopAnimation but it doesn't seem to affect anything.
This is what causes the drag to happen -
onPanResponderMove: (e, gestureState) => {
return Animated.event([null, {
dy: this.state.drag.y,
}])(e, gestureState)
},
Using {...this.panResponder.panHandlers}
on the view that users can drag to drag the whole drawer. Like a handle.
Using this.state.drag.getLayout()
in styles, on the view that I want to drag in response to dragging the 'handle'.
Any response is appreciated!