onTouchStart results in unexpected behavior
See original GitHub issueWith this line in place, merely scrolling past the image gallery with the scrolling finger touching the area of the gallery will result in the triggering of the custom onClick
method, which, in turn, might do things like opening a larger image on a modal; a very unexpected behavior and frustrating user experience.
The onClick
should trigger just fine on tap events on touch devices, there is no need to specify a separate onTouchStart
if the goal is simply to make sure that the custom onClick
method works on these devices. Is there any other reason for having included this line, or is it safe to remove it?
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
javascript - Weird touch/click events stack
I'm handling 5 events on a button - touchstart , touchend , mousedown , mouseup ... how to return the click event for...
Read more >beautiful-react-hooks/useTouchEvents.md at master - GitHub
Returns a set of handler setters to control touch events (onTouchStart, onTouchMove, onTouchEnd). It possibly accepts a DOM ref to target the event(s)...
Read more >Element: touchstart event - Web APIs - MDN Web Docs - Mozilla
The touchstart event is fired when one or more touch points are placed on the touch surface.
Read more >Implementing basic touch support in JavaScript - Jhey Tompkins
The result is that we need more events to listen for and bind to. Start the touch — touchstart; Listen for any movement...
Read more >Making touch scrolling fast by default - Chrome Developers
In rare cases this change can result in unintended scrolling. ... If you call preventDefault() in the touchstart or first touchmove events ...
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 FreeTop 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
Top GitHub Comments
Ah, okay. I’m going to close this issue then. Thanks!
No, scrolling happens properly regardless of being initiated on one of these elements or not, I was just commenting on the control handlers firing as a side-effect of scrolling, and not as an intended action in these cases. As I’ve said, this is a much less serious issue than the custom
onClick
handler firing on the main image’stouchstart
, ultimately you’re juggling two similarly frustrating mobile UX concerns, of which keeping one or the other will have to be a fairly subjective decision, so it’s really up to you. I’m already happy with the original issue being taken care of.