The delay option will help, but as you noticed, it won't solve all of
your problems. Delay was set up to not fire the drag if the user was
simply clicking. It won't work the other way 'round.
The trouble here is that Drag uses onmouseup, and the link uses
onclick, an event the Draggable doesn't observe.
An easy way to trap the onclick is (pseudo code):
function onEndDrag () { // make it an observer, pass it as an
option,.... whatever.
this.element._lastDrag = time();
}
function checkLinkDrag (evt) { // have this function observe the
onclick event of the link
if (!this._lastDrag) {return;}
if (time() - this._lastDrag < 200) { // Play with this a little bit
Event.stop(evt);
}
}
An even better way is to use handles for dragging (so you're not
dragging links). Than you won't have to deal with unwanted behavior.
TAG
On Apr 17, 2007, at 3:01 AM, arthur wrote:
>
> (this is my second attempt to answer, I don't know why, google skipped
> the first)
>
> First of all, thanks to all for the answers, I was not expected that,
> so quickly !
>
> On 14 avr, 14:12, Christophe Porteneuve <[EMAIL PROTECTED]> wrote:
>>
>> Hrm... You mean the delay option works, but when you do release the
>> drag, it ends up clicking?
>>
>
> In fact, at first I didn't even try the delay option, because it was
> still not documented on wiki.script.aculo.us.
> I just tried, and it works just like it should, thanks.
>
> If I do nothing more, when I release the drag, it ends up clicking,
> yes.
> I just want to not end up clicking in case of a drag.
>
> Ken's answer just implemented the solution I quote from in my first
> mail. Thanks a lot.
> I think it could be simplier with using the "change" function instead
> of the "startEffect" function to set tileMove to true if we want to
> keep startEffect defaults :
>
> var tileMoved = false;
>
> function makeDraggable(tileDiv) {
> new Draggable(tileDiv, {
> revert: true,
> reverteffect: function(el, yOffset, xOffset) {
> // A hack, using reverteffect() to do onDrop
> processing
> tileMoved=false; // Reset tile moved because
> we've already prevented the link
> },
> change: function(element) {tileMoved=true;} // my
> modification
> });
> }
> But it's still a hack, like you said !
>
> Justin's solution seems to me dangerous : there is nothing left in the
> endrop function, so we lost stopScrolling(), all the stuff in
> finishDrag(event, true), and the event is not stop :
> from dragdrop.js :
> endDrag: function(event) {
> if(!this.dragging) return;
> this.stopScrolling();
> this.finishDrag(event, true);
> Event.stop(event);
> },
>
> Could this solution raise problems ?
>
> Thanks a lot to all !
>
> Arthur
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---