Closed
Description
I have a ScrollView which contains a View inside.
When I move touch on the View, It will scroll the ScrollView too.
I woner is there a way to stopPropagation just like the DOM event does.
I have tried to set PanResponder like this,but It didn`t work
PanResponder.create({
onStartShouldSetPanResponder: function () {
return false;
},
onStartShouldSetPanResponderCapture: function () {
return false;
},
onMoveShouldSetPanResponder: function () {
return false;
},
onMoveShouldSetPanResponderCapture: function () {
return false;
},
onPanResponderTerminationRequest: function () {
return false;
}
});
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
joewood commentedon May 30, 2015
Having the same issue. I'm wondering if ShouldCapture events should return true if the movement is more horizontal than vertical. The documents are not great for the PanResponder API.
[-]How to stopPropagation touch event[/-][+][Touchable] How to stopPropagation touch event[/+]ghost commentedon Aug 4, 2015
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.
ericvicenti commentedon Aug 4, 2015
PanResponder.create({
will return an object, and you need to render a view with the responder handlers on it. For exmple:preventDefault
does not enable the touch responsiveness we want on native mobile. To make actions clear to the user, components should visibly respond for a given touch, and give up responder if something else needs it. Although the touch responder API isn't perfect, it should work for most things.Can you be more specific about what you are trying to do? Maybe post a minimal example of the issue on rnplay.org?
If you have any improvements to the gesture guide or the pan responder docs, feel free to make a pull request!
brentvatne commentedon Sep 10, 2015
@ericvicenti - I've had this issue myself as well - for example:
Inside of the horizontal ScrollView, at the bottom of each page there is a footer that can be pulled upwards. If you start pulling this up (
onStartShouldSetPanResponder
returns true) then the ScrollView should not do respond to any movement. The only solution I have for this right now is to lock the ScrollView when the gesture begins, and unlock it when it's released. There is a slight problem with this solution still because if you do just the right gesture so that it scrolls the ScrollView a little bit before setting the responder and locking the ScrollView, you end up in a weird state where you're locked in between pages. To handle this, I need to track the active page in the ScrollView and scroll it back to the right position when I lock it.The best solution would be to just be able to have the PanResponder become responder and block ScrollView. @vjeux mentioned that on Android there is a ~5px delay when the gesture starts before the ScrollView takes over, which gives the PanResponder a chance to respond. Maybe a similar solution is needed for iOS.
jukkatupamaki commentedon Jan 9, 2016
While trying to move a
SliderIOS
's knob,Navigator
starts the swipe back gesture at the same time. UsingPanResponder
to catch the touch start doesn't seem to help.Even though I use
PanResponder
to capture the touch event, theonMoveShouldSetPanResponder
callback gets called inNavigator
(react-native/Libraries/CustomComponents/Navigator/Navigator.js
Lines 612 to 614 in b9c5f75
jukkatupamaki commentedon Jan 10, 2016
I just noticed that the same bug exists in the UIExplorer example.
casperin commentedon Jan 29, 2016
I had the same problem. This response solved it for me. Essentially same as @tukkajukka's solution above, only with
rameshvishnoi90904 commentedon Mar 3, 2016
I also want to do same thing(Stop Panresponder after a given event).Please Help
()=>false
or configurable xinthink/react-native-material-kit#11444 remaining items