Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associating data with a drag #8

Open
danschultz opened this issue Jul 2, 2013 · 3 comments
Open

Associating data with a drag #8

danschultz opened this issue Jul 2, 2013 · 3 comments

Comments

@danschultz
Copy link
Contributor

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.

@marcojakob
Copy link
Owner

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.

@danschultz
Copy link
Contributor Author

This a common paradigm with Drag and Drop APIs. Off the top of my head, Java Swing, Flex, and HTML5 support behavior like this.

@marcojakob
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants