我正在尝试将缩放添加到SVG文档,但是在Firefox上未定义DOMMouseScroll event.wheelDelta。我也尝试过使用event.originalEvent.wheelDelta,这也是未定义的。我的代码适用于Chrome。这是我正在使用的代码,任何帮助将不胜感激。
var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel"
if (theSvgElement.attachEvent)
theSvgElement.attachEvent("on"+mousewheelevt, zoomViaMouseWheel)
else if (theSvgElement.addEventListener)
theSvgElement.addEventListener(mousewheelevt, zoomViaMouseWheel, false)
function zoomViaMouseWheel(mouseWheelEvent) {
if(mouseWheelEvent.wheelDelta > 0) {
alert('scrolling up ! ' + mouseWheelEvent.wheelDelta);
}
else{
alert('scrolling down ! ' + mouseWheelEvent.wheelDelta);
}
...
}