+ -
当前位置:首页 → 问答吧 → 请教如何在FireFox里画可拖动、可伸缩的直线

请教如何在FireFox里画可拖动、可伸缩的直线

时间:2009-01-12

来源:互联网

以下是我用 VML 在IE里面画直线的函数:直线作为一个对象,支持鼠标拖动事件,拖动时跟随光标伸缩;现在需要移植到FireFox里面,想用SVG实现,但从查到的资料看SVG中的直线好像不能做为单独的对象出现,也不支持鼠标事件,请高手指点一二。。。
    不限于SVG,如果有其它实现方案也可以。。。

function buildLine(xStart,yStart,xEnd,yEnd)
{ //alert(xStart+" "+yStart+" "+xEnd+" "+yEnd);
        var yEnd = parseInt(yEnd) - 12;
  var str = ""
  + "<v:line  id=" + this.lineId +" "
  + "from=\""
  + xStart + ","
  + yStart
  +"\"   to=\""
  + xEnd
  +","
  + yEnd
  + "\"   style=\"position:absolute;  cursor:move; z-index:-1; display:block;\" "
  + "onmousedown='startDrag(this)' "
  + "onmouseup='stopDrag(this)' "
  + "onmousemove='drag(this)' "
  +"/> ";
  //alert(this.id+this.lineId);
  if(this.haveLine==false) {
    document.body.insertAdjacentHTML("beforeEnd",str);
    this.haveLine = true;
  } else {
           var vlineOfNode = document.getElementById(this.lineId);
                vlineOfNode.from = xStart.toString()+","+yStart.toString();
                vlineOfNode.to = xEnd.toString()+","+yEnd.toString();
          vlineOfNode.style.visibility = '';
          vlineOfNode.strokecolor = "black";
        }
}

作者: wangsuw   发布时间: 2009-01-12

IE+SVG插件可以,在Firefox里还不太正常,调试中……

http://blog.donews.com/seven_ing/     svg+js直线的拖动与缩放

作者: wangsuw   发布时间: 2009-01-13

路过,对SVG不感兴趣

作者: naojin   发布时间: 2009-01-21