Hi,

I have a div which is draggable:
---8<----------
        <div id="mydiv"><a href="http://example.com";>Drag me!</a></div>
        <script>
        new Draggable('mydiv');
        </script>
---8<----------

The problem is when the user drags the link.
When the mouse button is released, the link is followed which is not
the expected behavior. :(

I've tried to stop the event. But nothing special happen.
---8<----------
        <div id="mydiv"><a href="http://example.com";>Drag me!</a></div>
        <script>
        new Draggable('mydiv', {
            onEnd:function(drag, evt) {
                Event.stop(evt);
            }
        });
        </script>
---8<----------

Actually the problem comes from mouse events.
"mousedown" -> start drag
"mousemove" -> drag
"mouseup" -> end drag
And finally "click" which is independant from mouseup and down.

The following code capture the click event if needed :
---8<----------
        <div id="mydiv"><a href="http://example.com";>Drag me!</a></div>
        <script>
        var has_just_been_dragged = false;
        $('mydiv').observe('click', function (evt) {
            if (has_just_been_dragged) {
                has_just_been_dragged = false;
                Event.stop(evt);
            }
        });
        new Draggable('mydiv', {
            onEnd:function() {
                has_just_been_dragged = true;
            }
        });
        </script>
---8<----------

It works but I don't like it...
Is there a more elegant way to achieve the expected behavior ?

Thanks,
Nicolas

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to