質問

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