I would like to take the mousewheel event on an element, but have't found anything on the documentation. Do you have an example of the kind?

有帮助吗?

解决方案

I'm not sure of any direct Snap methods to use mousewheel, but I guess you can just add a mousewheel listener...this example works in Chrome, you may need to tweak and add test case for different browsers.

var s = Snap(400, 620);
var c = s.circle(30,30,30);

if( (/Firefox/i.test(navigator.userAgent)) ) {
    s.node.addEventListener("DOMMouseScroll", mouseWheelHandler, false);
} else {
    s.node.addEventListener("mousewheel", mouseWheelHandler, false);
}

function mouseWheelHandler (ev) { 
    ev.preventDefault();
    console.log( ev.target.localName );
}

Edit: Have updated to check for firefox as well.

jsfiddle example

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top