[Touchable] How to stopPropagation touch event
See original GitHub issueI 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;
}
});
Issue Analytics
- State:
- Created 8 years ago
- Comments:33 (3 by maintainers)
Top Results From Across the Web
Touch events - Web APIs - MDN Web Docs - Mozilla
One technique for preventing things like pinchZoom on a page is to call preventDefault() on the second touch in a series. This behavior...
Read more >How to bind 'touchstart' and 'click' events but not respond to both
Use of the preventDefault() or stopPropagation() method: This method prevents the event handler from responding to both touchstart and clicks ...
Read more >Events and Mouse/Touch Events - The Web Platform Course
stopPropagation () , called to stop propagating the event in the DOM. and more. You can see the full list here. Each specific...
Read more >touchstart Event - W3Schools
Example. Execute a JavaScript when the user touches a P element (for touch screens only):. <p ontouchstart="myFunction(event)">Touch me!</p>.
Read more >Touch Events | Tizen Docs
Touch Events · touchstart handles an event which occurs when a finger comes in contact with the device screen. · touchmove handles an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I use
this.scrollView.setNativeProps({ scrollEnabled: false }
insideonPanResponderGrant
andthis.scrollView.setNativeProps({ scrollEnabled: true }
insideonPanResponderRelease
.this.scrollView
is set inside ref:<ScrollView ref={(c) => { this.scrollView = c; }} >
It works much faster than setting state variable and there is no scroll movement even if you swipe fast.
I had the same problem. This response solved it for me. Essentially same as @tukkajukka’s solution above, only with