Open robplaywind opened 3 years ago
Side note: this was done to make it easier to know what element was it dragged to to create a drag and drop UI
Looks like it could be related to this as well: https://github.com/playcanvas/engine/issues/2165
AFAIK, there was deliberate decision to have this behaviour because that is what the browser does (ie the mouse and touch events behave differently).
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 ifuseInput
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
ElementDragHelper
on an element.https://developer.chrome.com/docs/devtools/device-mode/#viewport
(reload Launch tab otherwise touch doesn't work properly).ElementDragHelper
object, setuseInput
to false on the element."touchEnd"
, if it was under the touch pointer."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.