pragmatic-drag-and-drop icon indicating copy to clipboard operation
pragmatic-drag-and-drop copied to clipboard

CSS transform on dragged element is not preserved by the dragged item

Open ericbiewener opened this issue 1 year ago • 3 comments

Screenshot 2024-09-24 at 6 27 25 AM

This appears to be a limitation of the HTML5 drag & drop API (Codepen indicating this), so feel free to close this issue if pragmatic doesn't offer a solution. Posting this in part just to have it discoverable by future devs.

One potential solution is of course to make a wrapping container draggable, rather than the transformed element itself. But this produces other visual issues, such as the clipping are on the dragged item including an opaque gray background, and potentially even some content outside the DOM of the dragged element (note the few pixels of purple on the left):

Screenshot 2024-09-24 at 6 42 40 AM

ericbiewener avatar Sep 24 '24 13:09 ericbiewener

I am also experiencing this issue and only on chrome. Screenshot 2024-09-25 at 10 42 28 AM

EarlStrada avatar Sep 25 '24 17:09 EarlStrada

Than use the shadow border usess to fix them

tarun111111 avatar Sep 27 '24 07:09 tarun111111

  • unfortunately, there are some known bugs with native drag previews (elements with transforms being one of them). The issue with transforms seems to impact Safari the most, so one option is to use the transform on Chrome, and disable the transform in onGenerateDragPreview for Safari
  • setCustomNativeDragPreview helps smooth over most issues if you haven't tried that

alexreardon avatar Sep 27 '24 08:09 alexreardon

Closing this, but feel free to re-raise if you have further questions 😄

michaelabrahamian avatar Dec 04 '24 22:12 michaelabrahamian