I had not thought about using addObserver and I momentarily
thought this cleaned up my messy solution.  But my problem
is that addObserver (as well as endeffect) only notify me
when this.dragging is true.  Since I want to destroy my
Draggable and remove some temporary DOM elements on mouseup
(regardless of whether or not the drag started), I need an
onDeactivateDraggable notification.

So I'll go take a stab at your first suggestion, inheritance
(which I have not yet used in javascript).

Much thanks,
Eric

On Aug 18, 2006, at 2:51 AM, Thomas Hervé wrote:

>
> Eric Waldheim a écrit :
>
>> Thanks again, I appreciate your input, your time, and DragAndDrop.js.
>
> Thanks for your feedback.
>
>> My actual application makes use of starteffect, endeffect, and snap
>> (for actually snapping) for numerous types of dragging (create/ 
>> resize/
>> move shifts and breaks) so I suspect I end up writing and maintaining
>> less code by using Draggable.
>>
>> Here's one more swag at the same thing.  I know that reaching into
>> the internals of MochiKit.DragAndDrop.Draggable is not a good thing,
>> but this solution cleans up up my application code and avoids
>> circular references, so it's a tradeoff I suspect I'll be willing to
>> make.
>
> OK that's your choice. But some of these internals methods may change,
> especially until 1.4 release.
>
>> And one additional piece: I added a check at the start of
>> my_mouse_down to end any currently active dragging (caused by mouse
>> up outside the document).  Is that a reasonable approach?
>
> Comments below.
>
>>      var p = MochiKit.DragAndDrop.Draggable.prototype;
>>      p.realEndDrag = p.endDrag;
>>      p.endDrag = function (event)
>>      {
>>              this.realEndDrag(event);
>>              this.cleanupDrag();
>>      }
>>      p.cleanupDrag = function ()
>>      {
>>              if (this.options.removeElementsOnMouseUp)
>>                      forEach(this.options.removeElementsOnMouseUp, 
>> removeElement);
>>              if (this.options.destroyOnMouseUp)
>>                      this.destroy();
>>      }
>
> Arg. Don't do this :). You can use inheritance, that would be better.
> The best thing to use in this case is the observer. You call
> MochiKit.DragAndDrop.Draggables.addObserver with an object with an
> onEnd method. See Sortable for an example.
>
>>
>> function my_mouse_down(event)
>> {
>>      var ds = MochiKit.DragAndDrop.Draggables;
>>      if (ds.activeDraggable)
>>      {
>>              ds.endDrag(event);
>>              return;
>>      }
>
> I think that's OK, but why do you return ? I'd just replace this code
> with:
>
> MochiKit.DragAndDrop.Draggables.endDrag(event);
>
> and I think it will make what you want (check active, and clean
> current).
>
> -- 
> Thomas
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to