WheelEvent

WheelEvent interface represents events that occur due to the user moving a mouse wheel or similar input device.

Important: This is the standard wheel event interface to use. Old versions of browsers implemented the non-standard and non-cross-browser-compatible MouseWheelEvent and MouseScrollEvent interfaces. Use this interface and avoid the non-standard ones.

Do not confuse the wheel event with the scroll event: The default action of a wheel event is implementation-defined. Thus, a wheel event doesn't necessarily dispatch a scroll event. Even when it does, that doesn't mean that the delta* values in the wheel event necessarily reflect the content's scrolling direction. Therefore, do not rely on delta* properties to get the content's scrolling direction. Instead, detect value changes to scrollLeft and scrollTop of the target in the scroll 事件。

构造函数

WheelEvent()
创建 WheelEvent 对象。

特性

This interface inherits properties from its ancestors, MouseEvent , UIEvent ,和 Event .

WheelEvent.deltaX 只读
返回 double representing the horizontal scroll amount.
WheelEvent.deltaY 只读
返回 double representing the vertical scroll amount.
WheelEvent.deltaZ 只读
返回 double representing the scroll amount for the z-axis.
WheelEvent.deltaMode 只读
Returns an unsigned long representing the unit of the delta* values' scroll amount. Permitted values are:
常量 描述
WheelEvent.DOM_DELTA_PIXEL 0x00 delta* values are specified in pixels.
WheelEvent.DOM_DELTA_LINE 0x01 delta* values are specified in lines.
WheelEvent.DOM_DELTA_PAGE 0x02 delta* values are specified in pages.

方法

This interface doesn't define any specific methods, but inherits methods from its ancestors, MouseEvent , UIEvent ,和 Event .

规范

规范 状态 Comment
UI Events
The definition of 'The WheelEvent interface' in that specification.
工作草案
Document Object Model (DOM) Level 3 Events Specification
The definition of 'WheelEvent' in that specification.
Obsolete 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
WheelEvent Chrome 31 Edge 12 Firefox 17 IE 9 Opera 18 Safari 6.1 WebView Android Yes Chrome Android Yes Firefox Android 17 Opera Android Yes Safari iOS No Samsung Internet Android Yes
WheelEvent() 构造函数 Chrome Yes Edge ≤18 Firefox 17 IE No Opera Yes Safari 6.1 WebView Android Yes Chrome Android Yes Firefox Android 17 Opera Android Yes Safari iOS No Samsung Internet Android Yes
deltaMode Chrome 31 Edge 12 Firefox 17 IE 9 Opera 18 Safari 6.1 WebView Android Yes Chrome Android Yes Firefox Android 17 Opera Android Yes Safari iOS No Samsung Internet Android Yes
deltaX Chrome 31 Edge 12 Firefox 17 IE 9
9
IE9 supports an old draft of the spec where this value was a long instead of a double .
Opera 18 Safari 6.1 WebView Android Yes Chrome Android Yes Firefox Android 17 Opera Android Yes Safari iOS No Samsung Internet Android Yes
deltaY Chrome 31 Edge 12 Firefox 17 IE 9
9
IE9 supports an old draft of the spec where this value was a long instead of a double .
Opera 18 Safari 6.1 WebView Android Yes Chrome Android Yes Firefox Android 17 Opera Android Yes Safari iOS No Samsung Internet Android Yes
deltaZ Chrome 31 Edge 12 Firefox 17 IE 9
9
IE9 supports an old draft of the spec where this value was a long instead of a double .
Opera 18 Safari 6.1 WebView Android Yes Chrome Android Yes Firefox Android 17 Opera Android Yes Safari iOS No Samsung Internet Android Yes
Pinch-to-zoom maps to WheelEvent + ctrl key. Chrome 31 Edge ≤79 Firefox 55 IE ? Opera ? Safari No WebView Android Yes Chrome Android Yes Firefox Android 55 Opera Android ? Safari iOS No Samsung Internet Android Yes

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
见实现注意事项。

另请参阅