以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 SVG/GML/VRML/X3D/XAML 』  (http://bbs.xml.org.cn/list.asp?boardid=21)
----  svg的鼠标滚轮事件  (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=66811)


--  作者:hfutzhu
--  发布时间:9/4/2008 2:28:00 PM

--  svg的鼠标滚轮事件
如何实现鼠标的滚轮事件,缩放svg图形?????
--  作者:hfutzhu
--  发布时间:9/4/2008 2:29:00 PM

--  
看了以前的帖子,说下面的代码可以实现:
function mousewheel()
{
   origscale=root.currentScale;
   origscale +=event.wheelDelta / 1200;
   if (origscale > 0)
   {
      root.currentScale=origscale;
      root.currentTranslate.x=midx*root.currentScale+event.offsetX*(1-root.currentScale/midscale);
   root.currentTranslate.y=midy*root.currentScale+event.offsetY*(1-root.currentScale/midscale);
      midscale=root.currentScale;
   midx=root.currentTranslate.x/root.currentScale;
   midy=root.currentTranslate.y/root.currentScale;
   }
}
不知道该怎么实现???/
--  作者:hfutzhu
--  发布时间:9/11/2008 9:32:00 AM

--  
怎么回事啊?没人回答!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
--  作者:hfutzhu
--  发布时间:9/11/2008 11:06:00 AM

--  
function zoomInOut(delta) {

 if (delta >= 0)
{
   SvgZoomIn()

}

    else

 
  }
   
  function wheel(event){
   var delta = 0;
 if (!event) event = window.event;
 if (event.wheelDelta) {
  delta = event.wheelDelta;
    if (window.opera) delta = -delta;
 } else if (event.detail) {
    delta = -event.detail/3;
 }

 if (delta)
  zoomInOut(delta);
         if (event.preventDefault)
                 event.preventDefault();
          event.returnValue = false;
}
  
if (window.addEventListener)
window.addEventListener('DOMMouseScroll',wheel,false);
window.onmousewheel = document.onmousewheel = wheel;


function SvgZoomOut()//放大

{
       SVGRoot.currentScale = SVGRoot.currentScale * vScaleFactor;


}
function SvgZoomIn()
{
        
       SVGRoot.currentScale = SVGRoot.currentScale / vScaleFactor;

 
}


这样写可以捕捉到滚轮事件,但是放大缩小里的执行不了,哪位兄弟帮忙啊????


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
8,080.078ms