From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../api/htmlelement/pointercancel_event/index.html | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 files/zh-cn/web/api/htmlelement/pointercancel_event/index.html (limited to 'files/zh-cn/web/api/htmlelement/pointercancel_event') diff --git a/files/zh-cn/web/api/htmlelement/pointercancel_event/index.html b/files/zh-cn/web/api/htmlelement/pointercancel_event/index.html new file mode 100644 index 0000000000..620ce654d3 --- /dev/null +++ b/files/zh-cn/web/api/htmlelement/pointercancel_event/index.html @@ -0,0 +1,101 @@ +--- +title: 'HTMLElement: pointercancel event' +slug: Web/API/HTMLElement/pointercancel_event +translation_of: Web/API/HTMLElement/pointercancel_event +--- +
{{APIRef}}
+ +

当浏览器认为不再会有更多的指针事件, 或者在 {{event("pointerdown")}} 事件触发之后用户滚动或者缩放窗口,pointercancel 事件被触发。

+ + + + + + + + + + + + + + + + + + + + +
BubblesYes
CancelableNo
Interface{{domxref("PointerEvent")}}
Event handler propertyonpointercancel
+ +

常见需要 pointercancel 事件的地方:

+ + + +
+

在 pointercancel 事件触发后,浏览器会按顺序发送 {{event("pointerout")}} 以及 {{event("pointerleave")}}。

+
+ +

示例

+ +

使用 addEventListener():

+ +
const para = document.querySelector('p');
+
+para.addEventListener('pointercancel', (event) => {
+  console.log('Pointer event cancelled');
+});
+ +

使用 onpointercancel 事件句柄属性:

+ +
const para = document.querySelector('p');
+
+para.onpointercancel = (event) => {
+  console.log('Pointer event cancelled');
+};
+ +

Specifications

+ + + + + + + + + + + + +
SpecificationStatus
{{SpecName('Pointer Events', '#the-pointercancel-event')}}{{Spec2('Pointer Events')}}
+ +

浏览器兼容性

+ + + +

{{Compat("api.HTMLElement.pointercancel_event")}}

+ +

参见

+ + -- cgit v1.2.3-54-g00ecf