https://github.com/RubaXa/Sortable/issues/146
https://kryogenix.org/code/browser/custom-drag-image.html
This should work
<draggable
v-model="items"
@start="modify"...
modify (e) {
let dragIcon = document.createElement('img')
dragIcon.src = 'https://www.google.no/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'
e.dataTransfer.setDragImage(dragIcon, 0, 0)
}
Sorry, it can be done with setData method ^^
Accepted types:
https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types
Example:
<draggable :options="{setData: modifyDragItem}"></draggable>
modifyDragItem (dataTransfer) {
let img = new Image()
img.src = 'https://www.google.no/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'
dataTransfer.setDragImage(img, 0, 0)
}
To achieve this in v2.20 or higher where options prop is deprecated, use setData directly, like:
<draggable :setData="modifyDragItem"></draggable>
JS part remains the same.
<draggable
v-model="actionClones"
:setData="customDragEl"
:group="groupName"
handle=".move-handle"
@start="startDrag"
@end="endDrag">
</draggable>
when I used this method, the draggable crashes after customDragEl and endDrag didn't get executed.
Edit: my workaround was to change the dragImage on
@dragStarton each draggable item
<draggable v-model="items" :group="groupName" handle=".move-handle" @end="endDrag">
<div
v-for="nth in items"
:key="nth.id"
:item_id="nth.id"
@dragstart="rewriteDragImg(nth, $event)"
>
...
</draggable>
<script>
...
rewriteDragImg(item, event) {
event.dataTransfer.setDragImage(event.originalTarget, 200, 0);
},
...
</script>
Most helpful comment
Sorry, it can be done with setData method ^^
Accepted types:
https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types
Example: