Snap.svg capturing mousewheel events

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?

Answers


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


Need Your Help

Is it possible to have “folders” in a database?

mysql database table directory folder

I am going to have a database with several (less than 10) "main" tables. Additionally to that I want to have hundreds or thousands tables of the same type (let same "user_1", "user_2", "user_3" and...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.