Happy to announce that the problem has gone. 

function givealift(e){
  if (draggedCtl!=null){
     var dX = e.clientX - clickedX;
     var dY = e.clientY - clickedY;
     var iX = parseInt(draggedCtl.getAttribute("x"));
     var iY = parseInt(draggedCtl.getAttribute("y"));
     clickedX = e.clientX;
     clickedY = e.clientY;
     var nX = dX+iX;
     var nY = dY+iY;

     draggedCtl.setAttribute("x",""+nX);
     draggedCtl.setAttribute("y",""+nY);

     
  }
}
function pickup(e){
  //this hack assigns mousemove handler to background <g> element
  //so that dragging was more smooth
  var bg = e.target.ownerDocument.getElementById("background");
  bg.setAttributeNS(null,"onmousemove","givealift(evt);");

  var ctl = (e.getTarget? e.getTarget() : e.target);

  clickedX = e.clientX;
  clickedY = e.clientY;
  origX = parseInt(ctl.getAttribute("x"));
  origY = parseInt(ctl.getAttribute("y"));

  draggedCtl = ctl;
}
function dropdown(e){
  var bg = e.target.ownerDocument.getElementById("background");
  bg.setAttributeNS(null,"onmousemove",null);
  draggedCtl = null;
}



--- In svg-developers@yahoogroups.com, "Nazar" <[EMAIL PROTECTED]> wrote:
>
> Hello, 
> 
> I am new to SVG and seeking for help. I have SVG document with
> semi-transparent <rect> object
> 
>     <rect id="infowindow" onmousedown="pickup(evt)"
> onmouseup="dropoff(evt)" onmousemove="givealift(evt)" x="626.0"
> y="117.0" fill-opacity="0.4" transform="matrix(1.0 0.0 0.0 1.0 -35.0
> 196.0)"
>          fill="#99ccff" width="240.0" filter="none" height="80.0"
> stroke="#000000" rx="4" ry="4"/>
> 
> 
> You see onmouseup, onmousemove, onmousedown attributes are assigned to
> javascript functions
> 
> moving = false;
> 
> function pickup(evt){
>       moving = true;
> }
> 
> function dropoff(evt){
>       moving = false;
> }
> function givealift(evt){
>       if(moving)moveObject(evt);
> }
> function moveObject(evt) {
>   var svgdoc = evt.getCurrentNode().getOwnerDocument();
>   obj=svgdoc.getElementById("infowindow");
>  
>
obj.setAttributeNS(null,"transform","translate("+evt.clientX+","+evt.clientY+")");
>   }
> 
> This functions are supposed to drag rect object but clicking rect
> snaps it to different position which user requires it would be.
>






-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to