HTML Drag & Drop nightmare

1 view
Skip to first unread message

Mike Austin

unread,
Dec 3, 2025, 4:58:46 PM (23 hours ago) Dec 3
to PiLuD
It's not news that the API is hard to use and get right. It's not 1 or 2 things, it's every aspect of the API. The "dragover" event allows you to query cursor position, etc. but literally polls (fires thousands of times while dragging) and eats up CPU.

My first version was so slow, you could see the list rows highlight seconds after you hovered over them! Maybe I could do it with CSS :hover? No, those selectors don't work in the middle of dragging. Last, ditch any logic in "dragover" (but is requires to call preventDefault) and add individual upper and lower <div>s with their own events.

It's actually very fast now, with 100 items.
Reply all
Reply to author
Forward
0 new messages