I am creating a Draggable element *after* the mousedown event that
starts the drag.
In this example, when I mousedown and mousemove in the container div
to create the Draggable div, the Draggable div is created and drags but
it appears
at document coords 0,0 instead of under the mouse.
Any insight into what I'm doing wrong is much appreciated.
Thanks.
Eric
I'm using Firefox and the latest MochiKit development version.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd";>
<html>
<head>

<style>
.invisible { display: none; }
</style>

<script type='text/javascript' src='MochiKit/MochiKit.js'></script>
<script type='text/javascript' src='MochiKit/New.js'></script>
<script type='text/javascript' src='MochiKit/Signal.js'></script>
<script type='text/javascript' src='MochiKit/DragAndDrop.js'></script>


<script type='text/javascript'>

window.onload = function()
{
   connect('container',"onmousedown",my_mouse_down);
        new Draggable($('existing_div'));
}

function my_mouse_down(event)
{
        var d =
DIV({'style':"background-color:#F00;top:"+event.mouse().client.y+"px;left:"+event.mouse().client.x+"px;height:20px;width:20px",'class':'invisible'});
        appendChildNodes('container', d);
        var z = new Draggable(d,
                                                                 
{starteffect:function(element) {
                                                                          
makeVisible(element);
                                                                  },
                                                                 });
        z.initDrag(event);
   return false;
}

function makeVisible(elem) {
   removeElementClass(elem, "invisible");
}

</script>
</head>
<body>
        <div id="container"
style="top:50px;left:50px;height:300px;width:300px;border:1px solid
black;position:relative">
        <div id="existing_div"
style="background-color:#0F0;top:10px;left:10px;height:20px;width:20px"></div>
        </div>
</body>
</html>


--~--~---------~--~----~------------~-------~--~----~
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