[Element.makeDraggable] position and droppables issues

55 views
Skip to first unread message

Alain ANDRE

unread,
May 14, 2013, 1:00:14 PM5/14/13
to mootool...@googlegroups.com
Hi guys,

I'm having some issues with Element.makeDraggable and I'd like some help to fix or make it better.

I need to drag some divs witch are in a overflowed div (artworks in example) and drop them into some other divs (albums in example) . So I create clones to play with all over the window. Thing is my window allow the user to update some parts of its and can offer some new droppable divs (added droppable in example).

1st problem :
This means that the droppables option in Element.makeDraggable must be refreshed. I did not find on the net and the http://mootools.net any informations about how to do this. The call of checkDroppables in the onDrag function does not deal this thing. So I looked into the source code and found there is no function to do that I implemented it in my code by overriding this.droppables on line 7 : this.droppables = $$('.amo-widget[data-type="album"]'); Now it works but I feel like it's not clean, so if some of you have a cleaner solution :p

2nd problem :
I had to override the drag function to put the clone on the position I wanted, but I'm not sure this is the best way as it does not do the Drag.drag() things  (cf onDrag in example)

I've made a little example on http://jsfiddle.net/wordsbybird/TAVfk/

Regards, Alain ANDRE.

Sanford Whiteman

unread,
May 14, 2013, 6:47:00 PM5/14/13
to Alain ANDRE
> 1st problem :
> This means that the droppablesoption in Element.makeDraggable must
> be refreshed. I did not find on the net and the http://mootools.net
> any informations about how to do this. The call of checkDroppables
> in the onDrag function does not deal this thing. So I looked into
> the source code and found there is no function to do that I
> implemented it in my code by overriding this.droppables on line 7 :
> this.droppables = $$('.amo-widget[data-type="album"]');Now it works
> but I feel like it's not clean, so if some of you have a cleaner solution :p

Based on a quick look, I think you're on the best track, but I think
you should abstract it out to attachDroppables/detachDroppables
accessors. This is probably worth a pull request IMO if you get it
working to your satisfaction.

> 2nd problem :
> I had to override the drag function to put the clone on the
> position I wanted, but I'm not sure this is the best way as it does
> not do the Drag.drag() things (cf onDrag in example)

Not sure what you mean by doesn't do the Drag.drag() as that internal
method is still fired before your event listener.

-- Sandy

Reply all
Reply to author
Forward
0 new messages