Thursday, August 7, 2008

$.event.special.wheel

A smaller, simplified interpretation of Brandon Aaron's special event "Mouse Wheel Extension" (http://plugins.jquery.com/project/mousewheel).

Download - jQuery 1.2.6+ required.

The event is called "wheel" and can be created using the "bind" method...

// bind a wheel event $(body).bind('wheel',function(event,delta){ alert( delta>0 ? "up" : "down" ); });

a "wheel" method is also created which behaves just like "click"

// trigger a wheel handler $(body).wheel(); // bind a wheel handler $(body).wheel(function(){ ... });

The second argument passed to the event handler, is the same normalized "delta" representation of scrolling used in the other mousewheel event (brandon aaron's), however that value is also stored in a delta property on the event object ("event.delta"). Firefox 3 has corrected the "DOMMouseScroll" event bug found in Firefox 2, so this plugin only fixes event properties (using mousemove) in versions of firefox prior to 3.

Demo - Mousewheel inside the three blocks below to cycle through colors.

Please direct any feedback to http://groups.google.com/group/threedubmedia