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

Only allow one element to drop #230

Closed
davidbarker1 opened this issue Oct 12, 2015 · 5 comments
Closed

Only allow one element to drop #230

davidbarker1 opened this issue Oct 12, 2015 · 5 comments
Labels

Comments

@davidbarker1
Copy link

Hi,

I'm trying to set up a droppable container which only allows one element to be dropped. After the container has an element dropped, any subsequent drop would cause the current dropped item to be programmatically dragged and dropped back to the originating container.

I can obviously manipulate the DOM but I would prefer a more intuitive experience to indicate the dropped area only allows one item.

This obviously isn't a feature of dragula but is it possible using the drop event?

Cheers

@Myrdivar
Copy link

Hi,

I'm interested in this topic too. Any info on how to achieve that?

@ben-pr-p
Copy link

Try removing the container from drake.containers after it has something dropped on it

You could also set an attribute like already-dropped on the DOM element and then check if that attribute exists in your accepts function

@Myrdivar
Copy link

Thanks for the reply ben. The first solution could work but in my case I need to leave the destination container in order to drag and drop away the only one element that should be present.

The second one is the solution I already adopted but sometimes it acts strangely. I haven't figured it out yet but once in a while when I drop an element the drop event fires, the attribute is set but the element dropped doesn't end up in the container (and in the dom).

@ben-pr-p
Copy link

Ok you could change the class of the container, so that initially it has an accepting class, but after one element is dropped it changes to leaving. Then you change it back and forth

@bevacqua
Copy link
Owner

bevacqua commented Nov 3, 2015

Use Slack for support requests. See #248.

@bevacqua bevacqua closed this as completed Nov 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants