I've come up with something that works for me, but it's not
extensively tested so I'm not sure if it's a good general purpose
solution. It's pretty simple though. The basic idea:
I added an option to the ui.draggable defaults called "catchable" with
a default value of false.
At the top of _mouseStart, right after the `var o = this.options`
line:
if (o.catchable && this.helper && this.helper.hasClass('ui-
draggable-dragging'))
return true;
This will capture the mouse while retaining the old info (position
etc.)
Finally my new _mouseCapture function for ui.draggable (cancels the
animation if the mouse is captured while animating):
_mouseCapture: function(event) {
var o = this.options;
if ((!o.catchable && this.helper) || o.disabled || $
(event.target).is('.ui-resizable-handle'))
return false;
//Quit if we're not on a valid handle
this.handle = this._getHandle(event);
if (!this.handle)
return false;
if (o.catchable && this.helper)
this.helper.stop();
return true;
},
That's it. Seems to work in my basic setup (FF3, absolutely
positioned elements, no callbacks) - just pass {catchable: true} to
your .draggable() call.
On Mar 25, 8:05 am, "Richard D. Worth" <[email protected]> wrote:
> There's no way to do this currently. If you do hack at the code, please
> share whatever you find. Thanks.
>
> - Richard
>
> On Tue, Mar 24, 2009 at 5:29 PM, ehaas <[email protected]> wrote:
>
> > Hi,
> > I was wondering if anyone knew a good way to make a draggable item
> > "grabbable" while it's in the revert animation? I have a fairly long
> > revert duration and it would be nice if the user could prevent the
> > revert by grabbing the item while it's in transit.
>
> > Here's how I declare my draggable:
>
> > $('.item').draggable({revert: true, revertDuration: 5000});
>
> > Near as I can tell, the problem arises because the "_mouseCapture"
> > function of ui.draggable has a check for whether the helper exists:
>
> > if (this.helper || o.disabled || $(event.target).is('.ui-resizable-
> > handle'))
> > return false;
>
> > I can't just remove this check because the item will continue to try
> > to revert. Basically I need a way to cancel the revert? Is there a
> > way to do this or do I need to start hacking the code?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery UI" 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/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---