reppners / ngx-drag-drop

Angular directives using the native HTML Drag And Drop API
https://reppners.github.io/ngx-drag-drop/
BSD 3-Clause "New" or "Revised" License
299 stars 118 forks source link

Define custom dndDragImageElementRef by code #59

Open ReactionCode opened 5 years ago

ReactionCode commented 5 years ago

I don't really know if my request is actuall possible, at least I can not achieve it with the actual version 1.1.0.

As far I know If I want to change the drag image I have to set the dndDragImageElementRef on any child element of a dragZone.

DRAG_IMAGE

The handicap appears when I want to set dndDragImageElementRef by code, to an element that is hidden to HTML, the drag image would be hidden too.

A solutions would be add a [dndDragImageRef]="draggable.dragImage as HTML attribute on DragZone, so on each drag start the drag image would be changed,

<div [dndDraggable]="draggable.data" [dndDragImageRef]="draggable.dragImage [dndEffectAllowed]="draggable.effectAllowed" [dndDisableIf]="draggable.disable (dndStart)="onDragStart($event)" (dndCopied)="onDraggableCopied($event)" (dndLinked)="onDraggableLinked($event)" (dndMoved)="onDraggableMoved($event)" (dndCanceled)="onDragCanceled($event)" (dndEnd)="onDragEnd($event)">

An example to this, would be the next screenshot https://pasteboard.co/I4lL16o.png

Other example https://material.angular.io/cdk/drag-drop/overview#customizing-the-drag-preview

If it's possible to achieve it, I would gratefull some advices.

Best regards. Javier.

reppners commented 5 years ago

Hi, thanks for your request. This is possible to implement.

To clarify:

Is that correct?

ReactionCode commented 5 years ago

It's correct!!

zaidas1m commented 3 years ago

Is the request implemented? I have an issue when the drag zone is under other container because imageDrag generated gets DOM element from the container is over. Is there a way to avoid this? Maybe sending the dragImage by param?