playcanvas / playcanvas/engine
Element still recieves touchend event if useInput=false
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
Description
The element dragging described here uses the ElementDragHelper object.
If an element starts to be dragged via mouse, and useInput is set to false on the dragging element after this, when it is dropped the element does not receive the "mouseup" event. This is the desired behavior as it allows me to know which element this dragged element was "dropped on" (The element under the cursor when the drag ends). This allows for UI drag and drop functionality.
The issue is that when touch is used (Desktop Google chrome touch emulation), the dragged element receives the touchend event, even if useInput is set to false. This is not desired, as the element under gets no event (because the dragged one got the event), meaning I cannot know what element should receive this drop.
Steps to Reproduce
- Setup a new
ElementDragHelperon an element. - Use google chrome mobile viewport:
https://developer.chrome.com/docs/devtools/device-mode/#viewport(reload Launch tab otherwise touch doesn't work properly). - Using the "drag:start" event from the
ElementDragHelperobject, setuseInputto false on the element. - Observe how when dragging ends via touch, the dragged element still receives
"touchEnd", if it was under the touch pointer. - Repeat and observe how the element does not receive
"mouseup"if it was under the cursor.
In my implementation, i use requestAnimationFrame() to wait a frame before setting useInput to false, but I do not think this should matter.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing ElementDragHelper's drag:start handling and the touchend and mouseup input paths. Reproduce the issue in Chrome mobile viewport with useInput set to false during dragging, then compare event targeting when the drag ends. Done means touch behavior matches mouse behavior: the dragged element does not receive touchend when useInput is false, allowing the element beneath it to receive the drop event.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100