如何判断SVG事件对象中的鼠标来源?
在SVG中會經常遇到判斷鼠標事件來源的問題,比如:鼠標單擊或者雙擊、滾輪事件等等。這里做一個簡單的介紹。
判斷鼠標是左鍵還是右鍵?
在onclick事件中,if(evt.button==0)則為左擊,否則為右擊
?????? 無論單擊還是雙擊evt.detail==1
判斷鼠標是單擊還是雙擊?
在onclick事件中,if(evt.detail==2)則為雙擊,否則為單擊
?
判斷鼠標的滾輪事件?
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;?
???}
}
轉載于:https://www.cnblogs.com/hetonghai/articles/748126.html
總結
以上是生活随笔為你收集整理的如何判断SVG事件对象中的鼠标来源?的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: Python 循环删除指定文件夹下所有的
- 下一篇: nupkg 本地安装_使用Nuget安装
