2 ms·
In a previous project I needed to customize the look of the "drag ghost", so I set up a global state for <thing being dragged>, and used requestAnimationFrame t
by wildrhythms 5y ago
In a previous project I needed to customize the look of the "drag ghost", so I set up a global state for <thing being dragged>, and used requestAnimationFrame to move the ghost around with the cursor. Drop-enabled elements would then listen for mouseup and check to see if something was being dragged. Lots of weird edge cases (what if the user moves the cursor off-screen?), so now I recommend using a library like React DnD or Dragula.