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

dropzone to support dropmove event #67

Closed
Izhaki opened this issue Aug 21, 2014 · 5 comments · Fixed by #71
Closed

dropzone to support dropmove event #67

Izhaki opened this issue Aug 21, 2014 · 5 comments · Fixed by #71

Comments

@Izhaki
Copy link

Izhaki commented Aug 21, 2014

Thanks for an excellent library that is exceptionally well written.

This is not exactly an issue, as I can easily work around it (and possibly I've missed something and you can already do it). But anyway I thought to impart knowledge and mention the following.

Drop abstractions

Nearly all DD libraries use draggables and dropzones - this is highly sensible. But if you really think about it from a software design perspective, you'll find that drops has two kinds:

  • Drop within - when the draggable is dropped within a container (or an element).
  • Drop in-between - when the draggable is dropped between two containers (or two elements).

TreeGrid example

For instance, I'm working on a tree-grid library where the widget may be used as a traditional tree (with some extra columns if one wishes) or as a table.

In both cases, when dragging a row (or a tree node) the drop is performed between two other rows (or tree nodes). In the case of trees at least, there can be an arbitrary amount of drop locations below or above each node (most notably, dropping below the bottom node will involve as many drop positions as the level of the node).

Thus, it is little-elegant to render a multitude of drop zones - it is much more sensible for the tree (or the table) to serve as a single drop zone that works out where drop is allowed as the use drags a proxy. Such single drop zone is also in charge of animations.

The request

It seems that at the moment there is no way for a dropzone to receive dragmove events. Given the above, I think such feature is sensible.

@taye
Copy link
Owner

taye commented Aug 23, 2014

Thanks for the request!

dragmove events for dropzones would be useful. The events would need a different name so that dropzones which are also draggables don't think that they're being dragged when something else is being dragged over them. How about "dropmove"? ¯(°_o)/¯

I think that having an event object like this would be good:

{
  target: dropzoneElement,
  dragmove: dragmoveEvent,
  type: 'dropmove'
}

@Izhaki
Copy link
Author

Izhaki commented Aug 26, 2014

Yep, dropmove distinction is obviously a must.

Whatever the event object's like, I envision this will be how you use it:

interact('.dropzone')
    // enable draggables to be dropped into this
    .dropzone(true)
    // listen for drop related events
    .on('dropmove', function (event) {
        // Do something here
    });

Just as a final note, I assume dropmove events will only be fired between the dropzone's dragEnter and dragLeave events.

@Izhaki Izhaki changed the title dropzone to support dragmove event dropzone to support dropmove event Aug 26, 2014
@taye
Copy link
Owner

taye commented Sep 1, 2014

I've added the dropmove event in #71. Please try it and let me know how it goes.

https://raw.githubusercontent.com/taye/interact.js/dropmove-event/interact.js

@Izhaki
Copy link
Author

Izhaki commented Sep 2, 2014

Thanks for implementing this so quickly; all seem to be working.

Just one comment... having looked at setOnEvents it seems that currently the following syntax isn't supported:

        interact( element[0] ).dropzone({
            dropmove:  ctrl.onDropMove,
            drop:      ctrl.onDrop
        });

Although not a big deal, perhaps this is something worth adding.

@taye
Copy link
Owner

taye commented Sep 4, 2014

Thanks for mentioning that. It should be fixed now.

@taye taye closed this as completed in #71 Sep 4, 2014
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

Successfully merging a pull request may close this issue.

2 participants