문제

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