question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onTouchStart results in unexpected behavior

See original GitHub issue

With 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:closed
  • Created 7 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
xiaolincommented, May 20, 2016

Ah, okay. I’m going to close this issue then. Thanks!

0reactions
gaborlukcommented, May 20, 2016

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’s touchstart, 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found