中国企业信息网官方网站,平台维护工作内容,企业邮箱登录入口手机网页版,上海营销网站在SVG中会经常遇到判断鼠标事件来源的问题#xff0c;比如#xff1a;鼠标单击或者双击、滚轮事件等等。这里做一个简单的介绍。 判断鼠标是左键还是右键#xff1f; 在onclick事件中#xff0c;if(evt.button0)则为左击#xff0c;否则为右击 无论单击还是双击evt.detail…在SVG中会经常遇到判断鼠标事件来源的问题比如鼠标单击或者双击、滚轮事件等等。这里做一个简单的介绍。 判断鼠标是左键还是右键 在onclick事件中if(evt.button0)则为左击否则为右击 无论单击还是双击evt.detail1 判断鼠标是单击还是双击 在onclick事件中if(evt.detail2)则为双击否则为单击 判断鼠标的滚轮事件 function mousewheel(){ origscaleroot.currentScale; origscale event.wheelDelta / 1200; if (origscale 0) { root.currentScaleorigscale; root.currentTranslate.xmidx*root.currentScaleevent.offsetX*(1-root.currentScale/midscale); root.currentTranslate.ymidy*root.currentScaleevent.offsetY*(1-root.currentScale/midscale); midscaleroot.currentScale; midxroot.currentTranslate.x/root.currentScale; midyroot.currentTranslate.y/root.currentScale; }} 转载于:https://www.cnblogs.com/hetonghai/articles/748126.html