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