ObaidUrRehman / ng-drag-drop

Drag & Drop for Angular - based on HTML5 with no external dependencies. :tada:
MIT License
240 stars 123 forks source link

Please add documentation for changing cursor while dragging when Ctrl-key is pressed/released #187

Closed WineBewes closed 3 years ago

WineBewes commented 3 years ago

I know this package is discontinued, but I really like it because it's so lightweight (eg. no dependencies to @angular/material which I don't use). However, there's one piece of information I was missing, and that was how to change the cursor while dragging when the Ctrl-key is pressed/released. I found the solution, and maybe this little bit of information could be included in the documentation ? I tested in Chrome & Edge.

  1. On the draggable element, in the html, bind to the (OnDragStart), (OnDragOver) and (OnDragLeave) events (e.g. (onDragStart) = "onItemDragStart($event)" (onDragOver)="onItemDragOver($event)" (onDragLeave)="onItemDragLeave($event))

  2. In the component.ts file, add the following :

    onItemDragStart(event) { event.dataTransfer.dropEffect = event.ctrlKey ? 'copy' : 'move'; } onItemDragOver(event) { event.dataTransfer.dropEffect = event.ctrlKey ? 'copy' : 'move'; } onItemDragLeave(event) { event.dataTransfer.dropEffect = event.ctrlKey ? 'copy' : 'move'; }

This will change the cursor when you press/release the ctrl-key.

I don't find this information in the documentation. Perhaps you can add it ?

ObaidUrRehman commented 3 years ago

@WineBewes I am amazed as to how many downloads this package gets, even after 3 years since I deprecated this. Would you mind sending a PR with the proposed changes?