Brief introduction
IE6 implements the mouse wheel event MouseWheel, which contains a property that the mouse event does not have, Wheeldelta, which
Attribute values are always multiples of 120, and slide up one unit, the Wheeldelta value is 120, and the downward is-120. Then Chrome,opera,
The event is also implemented by Safari. Opera10 Previous version of the Wheeldelta value of the symbolic processing error, need to be modified. But Firefox didn't
There is this event, but instead use Dommousescroll. This event is only supported by Firefox, so it can be individually compatible with Firefox.
In addition, in order to be compatible with these two events, HTML5 also provides a standard version of the wheel event, compared to the new browser basically implemented the event.
Chrome31+,firefox 17+,ie9+,safari 7.0.5 and the new version of opera using the WebKit kernel, opera using the Carakan kernel
The event is not supported. The wheel event has the DeltaX, DeltaY, and Deltaz properties, which default to 100.
In summary, the current compatibility of wheel events is not ideal, mousewheel compatibility is best, applicable to all except Firefox browser, for
Firefox is compatible with the individual.
1Addevent =function (type,callback,usecapture) {2 if(window.addeventlistener) {3 This. AddEventListener (Type,callback,!!usecapture);4}Else if(window.attachevent) {5 This. attachevent (' on'+type,callback);6 }7 returncallback;8 }9Wheel =function (el,callback) {Ten varType ='MouseWheel'; One Try{ ADocument.createevent ('mousescrollevents'); -Type ='Dommousescroll'; -}Catch(e) {} theEl.addevent =addevent; - el.addevent (Type,function (e) { -E = e | | Window.Event; - varWheeldelta,delta; + if('Wheeldelta' inche) { -Wheeldelta = E.wheeldelta;//Positive scroll up + if(Window.opera && window.opera.version () <Ten){ AE.delta = parseint (-wheeldelta)/ -;//Wheeldelta under Safari is a floating-point number at } -E.delta = parseint (Wheeldelta)/ -; -}Else if('Detail' inche) { -E.wheeldelta =-e.detail * +;//fix Firefox without Wheeldelta bug,detail for +-3 -E.delta = E.wheeldelta/ -; - } in Callback.call (el,e); - //Stop bubbling Up toE.stoppropagation &&e.stoppropagation (); + if("stopbubble" inche) e.stopbubble =true; - return false; the},false); *};
Introduction to Mouse wheel events