race604 / react-native-viewpager

[Deprecated] ViewPager component for React Native
1.41k stars 373 forks source link

PanResponder should capture touches during the whole horizontal swipe #134

Open kballenegger opened 7 years ago

kballenegger commented 7 years ago

The logic that the PanResponder uses in order to determine when to capture moves is not ideal. Put the pager within a ListView or vertical ScrollView and it becomes instantly obvious, because a minimal amount of up-or-down movement will cancel the pager drag, animate to the closest page, and scroll the view up and down.

dubiao commented 7 years ago

+1

jacksontbryan commented 7 years ago

So as far as I can tell in React Native a child component cannot stop propagation to a parent. This component has a hasTouch event handler that is fired if the parent passed in a function. What I did is disabled the Scrollable property of the scroll view when hasTouch indicates true and re-enabled when hasTouch indicates false. I had to fix a bug with componentWillReceiveProps inside of the viewpager component as it would reset the page back to 0 when i changed the scrollable property of the parent.