Thank you peter, that's very helpful. Thank u nic as well.

On Feb 12, 2:54 am, Peter Edwards <[email protected]> wrote:
> the event order is mousedown->mouseup->click
> the 'dragend' event is triggered by mouseup, which happens before the
> click event, so if you put logic in your function dragged() to prevent
> clicked() from doing whatever it does, then the click event which is
> triggered at the end of a drag should be neutralised. The following
> approach uses a global boolean variable as a switch.
>
> var afterDrag = false
> function draggged() { afterDrag = true; }
> function clicked(){
>   if (afterDrag) {
>     afterDrag = false;
>     return;
>   }
>
> }
>
> Another approach would be to cancel events in the dragged() function
> somehow, but my knowledge of the event model doesn't extend that far
> (can a mouseup event cancel the click event which follows it?)
>
> on 12/02/2009 00:43 legofish said::
>
> > no takers?
>
> > On Feb 11, 1:54 pm, legofish <[email protected]> wrote:
>
> >> Hi,
>
> >> I am using the "drag" plugin (http://blog.threedubmedia.com/2008/08/
> >> eventspecialdrag.html) to design some interactions for a UI element.
>
> >> The element foo, needs to respond to a click, as well as to a drag
> >> (different responses for each). The plugin gives you handy drag events
> >> to work with.
>
> >> So I have:
> >> $("#foo").bind('dragend', function(e){   dragged()   });
> >> $("#foo").bind('click', function(e){   clicked()   });
>
> >> When foo is simply clicked on, then clicked() is executed and all is
> >> well.
> >> However, when foo is dragged, dragged() is called and right after that
> >> clicked() is called as well.
> >> I don't want clicked() to be called when foo is dragged, but I can't
> >> seem to figure out how to avoid that. Help is much appreciated.

Reply via email to