I've been trying to write a simple web app that uses drag and drop.
It works fine on a desktop with a mouse, capturing "dragstart" and
"dragend" for the draggable=true element and capturing "dragenter", "dragover" and "drop" on the target element.
I added listeners for "touchstart" and "touchend" and had the latter
simply call my drop handler function. And that got it to work with
the touchscreen on my windows laptop, but no dice on an android
phone. Is there an extra trick I didn't describe doing here? I'm calling event.preventDefault() in the handlers for "dragenter" and "dragover".
Do I need to prevent the default action with "touchstart" ?
On Tuesday, June 6, 2023 at 9:24:51 PM UTC-5, luserdroog wrote:
I've been trying to write a simple web app that uses drag and drop.
It works fine on a desktop with a mouse, capturing "dragstart" and "dragend" for the draggable=true element and capturing "dragenter", "dragover" and "drop" on the target element.
I added listeners for "touchstart" and "touchend" and had the latter simply call my drop handler function. And that got it to work withSome further searching suggests the answer might be to work with Pointer events rather than Touch and/or Drag&Drop. It seems that some of the
the touchscreen on my windows laptop, but no dice on an android
phone. Is there an extra trick I didn't describe doing here? I'm calling event.preventDefault() in the handlers for "dragenter" and "dragover".
Do I need to prevent the default action with "touchstart" ?
Touch api on android chrome might be trying to use a deprecated Element.setCapture() method.
[...]
After much fumbling and fretting, the only "trick" I've found in getting it to work was adding "touch-action:none" very precisely in the css. If I put it
around the whole table then you couldn't scroll away once you scroll the table into view, so it had to be just on the "TD" element that I wanted to manipulate. I had to learn and use the :has() whachacallit (pseudoclass?).
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 353 |
Nodes: | 16 (2 / 14) |
Uptime: | 21:02:49 |
Calls: | 7,646 |
Calls today: | 2 |
Files: | 12,809 |
Messages: | 5,697,758 |