JS wheel events onmousewheel usage introduction
- 2020-03-26 21:46:04
- OfStack
Mousewheel events are used in typical applications where the Mousewheel is used to control the size of an image or text. In most browsers (IE6, IE7, IE8, Opera 10+, Safari 5+), the mousewheel event is provided. The compatibility differences of the wheel event are somewhat eclectic. It is not ie8-pie and other pie, but FireFox pie and other pie. Unfortunately, FireFox 3.5+ does not support this event.
//IsFirefox is pseudo-code that you can implement yourself
mousewheel = isFirefox ? "DOMMouseScroll" : "mousewheel";
" mousewheel " In the event " event.wheelDelta " Property value: the value returned, if positive value means that the roller is scrolling up, if negative value means that the roller is scrolling down; The values returned are all 120 A multiple of, that is, the magnitude of the amplitude = The value returned / 120 .
" DOMMouseScroll " In the event " event.detail " Property value: the value returned, if negative, indicates that the wheel is scrolling up (with " event.wheelDelta " If it is positive, it means the wheel is rolling down. The values returned are all 3 A multiple of, that is, the magnitude of the amplitude = The value returned / 3 .
" mousewheel " In the event Opera 10+ Is a special case, existing " event.wheelDelta " Properties, too " event.detail " Properties.