Chris
any chance you could send some "Playground ready" code so we could poke around with it/find work around/ post a bug in github?
--- On Fri, 7/24/09, Chris <chri...@gmail.com> wrote: |
Chris,
I tried to adapt a drag and drop example I have on my website and found the same with that method. FF assumes horizontal and verticle movement relative to it's rotated position.
However I adapted the example a bit and the mouse does stay with the primitives if you
alter the rotation at the point the user selects the object and then (finally) inverts the temporary change when the user drops the primitive.
The crude hack below spins the object as you drag it but at least it stays with the mouse.
The below works in playground..
/*Drag and Drop aggregate objects demo from the project page(Key:Performance-DragDrop)*/ var isDrag = false; var boxWithLines=new Array(); var rectangles=new Array(); var lines=new Array(); var texts=new Array(); var shapes=new Array(); var nextColour=""; var textMessage=null; paper.text(300, 300,"Select one of the boxes and drop it where you like.").attr("fill", "BLUE").attr("font-size", "14"); /*Captures the event object*/ var dragger = function (e) { this.dx = e.clientX; this.dy = e.clientY; isDrag = this; this.animate({"fill-opacity": .2}, 500); }; for(var i=0; i<5;i++) { nextColour = Raphael.getColor(); boxWithLines[i] = paper.set(); rectangles[i]=paper.rect(90 + (i*60), 80, 60, 40, 10); lines[i]=paper.path({stroke: nextColour}).moveTo(90 + (i*60), 100).lineTo(150 + (i*60), 100); texts[i]=paper.text(120 + (i*60), 90,"#"+i).attr("fill", nextColour).attr("font-size", "14");; boxWithLines[i].push(rectangles[i]); boxWithLines[i].push(lines[i]); boxWithLines[i].push(texts[i]); shapes.push( rectangles[i] ); shapes[i].rotate(10*i); } for (var i = 0, ii = shapes.length; i < ii; i++) { nextColour = Raphael.getColor(); shapes[i].attr({fill: nextColour, stroke: nextColour, "fill-opacity": 0, "stroke-width": 2}); shapes[i].node.style.cursor = "move"; shapes[i].mousedown(dragger); //Add an index variable to all the shape objects shapes[i].index=i; } /*Playground note 1 of 3-'parent' prefix*/ parent.document.onmousemove = function (e) { /*Playground note 2 of 3-'window.event' transposed with 'event'*/ e = e || event; if (isDrag) { isDrag.rotate(isDrag.index*-10); isDrag.translate(e.clientX - isDrag.dx, e.clientY - isDrag.dy); /*Have to move the associated objects relatively and the image as only the rectangle would move*/ lines[isDrag.index].translate(e.clientX - isDrag.dx, e.clientY - isDrag.dy); texts[isDrag.index].translate(e.clientX - isDrag.dx, e.clientY - isDrag.dy); paper.safari(); isDrag.dx = e.clientX; isDrag.dy = e.clientY; } }; /*Playground note 3 of 3-'parent' prefix*/ /*Setup the 'drop' for the mouse release*/ parent.document.onmouseup = function () { if(isDrag) { if(textMessage!=null)textMessage.remove(); isDrag.rotate(isDrag.index*10); textMessage=paper.text(300, 320,"You just dropped box #"+ isDrag.index + " and you nearly broke it!").attr("fill", "RED").attr("font-size", "16"); } isDrag && isDrag.animate({"fill-opacity": 0}, 500); isDrag = false; }; |
|