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.

touchmove doesn't fire on removed element

See original GitHub issue

If you have

{this.state.show &&
  <div onTouchStart={this.hideTheDiv} onTouchMove={...} />}

such that the onTouchStart handler removes the div (and maybe replaces it with another one in the same place, useful in certain draggable interactions), the onTouchMove handler doesn’t fire because the events of a detached element no longer bubble to document. We should probably bind the touchmove handler when the element receives touchstart instead of delegating to document.

Sort of related to #1254.

cc @merbs @eater

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:2
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ZitRoscommented, Aug 18, 2020

touchmove and touchend events should always stick to the touchstart target. Check this answer for the correct implementation.

I believe in react this can be implemented manually with the user of ref now. However, as for React’s onTouchStart/onTouchMove/onTouchEnd, I would expect them all to be bound to the onTouchStart target.

0reactions
Nazeeh21commented, Jul 24, 2021

I have been reading all the comments on this issue. So far, I understood that onTouchMove/onTouchEnd events should be bind to the onTouchStart event. If I got it correctly I would like to give it a try to fix this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Touch Move event don't fire after Touch Start target is removed
This works for Mouse events, but doesn't work for Touch events. They don't fire after Touch Start target element is removed.
Read more >
Element: touchmove event - Web APIs | MDN
The touchmove event is fired when one or more touch points are moved along the touch surface.
Read more >
touchstart Event - W3Schools
Execute a JavaScript when the user touches a P element (for touch screens only): ... Note: The touchstart event will only work on...
Read more >
How to bind 'touchstart' and 'click' events but not respond to both
But a click event is fired when the user clicks an element. ... So, in this case, if the browser fires both touch...
Read more >
Implementing basic touch support in JavaScript - Jhey Tompkins
It's all about events · Start the touch — touchstart · Listen for any movement during the touch to handle gestures — touchmove...
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