dart-html5-dnd
dart-html5-dnd copied to clipboard
Associating data with a drag
You can't associate any data to a drag. It'd be convenient to do:
var dragGroup = new DraggableGroup();
var person = new Person()
..name = 'David Gilmour';
dragGroup.install(personDiv, data: person);
var dropGroup = new DroppableGroup();
dropGroup.onDrop.listen((DropzoneEvent event) => print(event.data.name));
dropGroup.accept.add(dragGroup);
Supporting this with installAll()
is a bit trickier.
I think you'd better associate such data outside of the drag and drop. You could, for example, keep a map with the element's id and the associated Person. Then, when a drag occurred, you can look up the id of the dragged element.
This a common paradigm with Drag and Drop APIs. Off the top of my head, Java Swing, Flex, and HTML5 support behavior like this.
Yes, HTML5 does support this, but then you would need to serialize your data (I assumed from your example with person that you didn't mean to serialize Person
).
In HTML5, the benefit of adding data to a drag operation is that another application could do something with the associated data (like dragging an image to the desktop). As this is not supported in IE9 I chose not to implement it.
Currently, I don't see a big benefit of adding this to the library. If you think otherwise, could you add more details about your use case?