dragon-drop icon indicating copy to clipboard operation
dragon-drop copied to clipboard

Feature Request: Support for ng2-dragula

Open lcecil opened this issue 6 years ago • 2 comments

I'm working on an project that uses Angular 6 and would like to use this library for the keyboard interactions, and the Angular 2 bridge for dragula for the mouse interactions (ie. ng2-dragula).

In my project, I have a list of items that are sorted by a position property. When you re-order the items on the list, via dragging an item with the mouse or keyboard, the position property for all the items in the array is updated.

ng2-dragula has a new event available in the service called dropModel; an observable that sends over a few properties, most notably the targetModel, so I can easily update the positions of each item in the array. This takes care of the above paragraph for mouse interactions.

However, I'm struggling a bit when using this library to figure out how to do this for the keyboard interactions. I have some ideas for features that could make this easier:

  1. Include the array of items in the .on('dropped') callback function, so that there's some way to determine new positions with the dropped item.
  2. Add a property to the options object that lets you pass in the dragula/drake instance created with ng2-dragula. As it stands now, I think I'm creating two - one with your lib, and one with ng2-dragula. Not sure this would solve my problem with the keyboard events though.
  3. Other?

Please let me know if there is something I'm missing or any other ideas you may have.

lcecil avatar Aug 29 '18 17:08 lcecil

@lcecil Let me look into this and get back to you as I am not familiar with this Angular 2 bridge for dragula. As for your idea 1 (Include the array of items in the .on('dropped') callback function) - this can easily be done and I'm happy to add support for this.

schne324 avatar Aug 30 '18 03:08 schne324

Thanks, I appreciate it.

Idea 1 would be a great interim solution, when you have the time to implement that. Right now I'm hooking into the reorder function of the announcement object, but that definitely doesn't seem like the intended purpose.

Also wanted to say thanks for being so responsive and building this lib in the first place! It's excellent.

lcecil avatar Aug 30 '18 15:08 lcecil