JavaScript/wheel:修订间差异
来自康健生活
| (未显示同一用户的8个中间版本) | |||
| 第7行: | 第7行: | ||
== mousewheel == | == mousewheel == | ||
触摸板的双指操作行为触发 mousewheel 事件。 | 触摸板的双指操作行为触发 mousewheel 事件。 | ||
=== 双指 === | |||
{| class="wikitable" | |||
|+ 双指操作行为 | |||
|- | |||
| 上滑动 || 下滑动 || 左滑动 || 右滑动 || 放大 || 缩小 | |||
|} | |||
==== 快速滑动 ==== | |||
{| class="wikitable" | |||
|- | |||
! !! 方向 !! 值域 | |||
|- | |||
| deltaX || 示例 || 示例 | |||
|- | |||
| deltaY || 示例 || 示例 | |||
|- | |||
| deltaZ || 示例 || 示例 | |||
|} | |||
==== 缓慢滑动 ==== | |||
{| class="wikitable" | |||
|- | |||
! !! 方向 !! 值域 | |||
|- | |||
| deltaX || 示例 || [-3, 3] | |||
|- | |||
| deltaY || 示例 || [-3, 3] | |||
|- | |||
| deltaZ || 示例 || 示例 | |||
|} | |||
==== 放大/缩小 ==== | |||
这里对比一个<code>放大/缩小</code>和<code>向上/向下/向左/向右</code>的动作。 | |||
{{hcdiff|head= wheel |output=<syntaxhighlight lang="bash" highlight="11"> | |||
isTrusted: true | |||
altKey: false | |||
bubbles: true | |||
button: 0 | |||
buttons: 0 | |||
cancelBubble: false | |||
cancelable: true | |||
clientX: 491 | |||
clientY: 339 | |||
composed: true | |||
ctrlKey: true | |||
currentTarget: null | |||
defaultPrevented: true | |||
deltaMode: 0 | |||
deltaX: -0 | |||
deltaY: 5.265862464904785 | |||
deltaZ: 0 | |||
detail: 0 | |||
eventPhase: 0 | |||
fromElement: null | |||
layerX: 491 | |||
layerY: 339 | |||
metaKey: false | |||
movementX: 0 | |||
movementY: 0 | |||
offsetX: 492 | |||
offsetY: 340 | |||
pageX: 491 | |||
pageY: 339 | |||
path: (9) [main#boardDocumentDrag.board-document-drag, div.board-document, div.container, div, div#app, body#syno-nsc-ext-gen3.ext-webkit.ext-chrome.ext-mac, html.ext-strict, document, Window] | |||
relatedTarget: null | |||
returnValue: false | |||
screenX: 491 | |||
screenY: 418 | |||
shiftKey: false | |||
sourceCapabilities: null | |||
srcElement: main#boardDocumentDrag.board-document-drag | |||
target: main#boardDocumentDrag.board-document-drag | |||
timeStamp: 64205.89999999106 | |||
toElement: main#boardDocumentDrag.board-document-drag | |||
type: "wheel" | |||
view: Window {window: Window, self: Window, document: document, name: '', location: Location, …} | |||
wheelDelta: -240 | |||
wheelDeltaX: 0 | |||
wheelDeltaY: -240 | |||
which: 0 | |||
x: 491 | |||
y: 339 | |||
[[Prototype]]: WheelEvent</syntaxhighlight>|output2=<syntaxhighlight lang="bash" highlight="11"> | |||
isTrusted: true | |||
altKey: false | |||
bubbles: true | |||
button: 0 | |||
buttons: 0 | |||
cancelBubble: false | |||
cancelable: true | |||
clientX: 648 | |||
clientY: 331 | |||
composed: true | |||
ctrlKey: false | |||
currentTarget: null | |||
defaultPrevented: true | |||
deltaMode: 0 | |||
deltaX: -6 | |||
deltaY: -0 | |||
deltaZ: 0 | |||
detail: 0 | |||
eventPhase: 0 | |||
fromElement: null | |||
layerX: 648 | |||
layerY: 331 | |||
metaKey: false | |||
movementX: 0 | |||
movementY: 0 | |||
offsetX: 648 | |||
offsetY: 331 | |||
pageX: 648 | |||
pageY: 331 | |||
path: (9) [main#boardDocumentDrag.board-document-drag, div.board-document, div.container, div, div#app, body#syno-nsc-ext-gen3.ext-webkit.ext-chrome.ext-mac, html.ext-strict, document, Window] | |||
relatedTarget: null | |||
returnValue: false | |||
screenX: 648 | |||
screenY: 410 | |||
shiftKey: false | |||
sourceCapabilities: null | |||
srcElement: main#boardDocumentDrag.board-document-drag | |||
target: main#boardDocumentDrag.board-document-drag | |||
timeStamp: 87451.29999999702 | |||
toElement: main#boardDocumentDrag.board-document-drag | |||
type: "wheel" | |||
view: Window {window: Window, self: Window, document: document, name: '', location: Location, …} | |||
wheelDelta: 18 | |||
wheelDeltaX: 18 | |||
wheelDeltaY: 0 | |||
which: 0 | |||
x: 648 | |||
y: 331 | |||
[[Prototype]]: WheelEvent | |||
</syntaxhighlight>}} | |||
双指<code>放大/缩小</code>,只有 <code>ctrlKey</code> 值为 <code>true</code>,并且几乎只有 <code>deltaY</code> 发生变化,放大时 <math>deltaY < 0</math>,缩小时 <math>deltaY > 0</math>。 | |||
===== 实现 ===== | |||
=== 监听 wheel 结束 === | |||
== 属性 == | == 属性 == | ||
| 第19行: | 第152行: | ||
* 使用触摸板触发事件,由于系统的平滑处理,会触发多次事件。 | * 使用触摸板触发事件,由于系统的平滑处理,会触发多次事件。 | ||
* IE 下无法使用触摸板触发该事件。{{Qm|有待验证}} | * IE 下无法使用触摸板触发该事件。{{Qm|有待验证}} | ||
== 滚动事件参考 == | |||
<pre> | |||
事件 浏览器 | |||
wheel Chrome(31+), FF(17+), IE(9+) | |||
mousewheel Chrome, IE(6+), Opera, Safari | |||
MozMousePixelScroll FF(3.5 only!) (2010-2013) | |||
DOMMouseScroll FF(0.9.7+) since 2003 | |||
</pre> | |||
== error == | == error == | ||