--- title: 'HTMLElement: pointercancel event' slug: Web/API/HTMLElement/pointercancel_event translation_of: Web/API/HTMLElement/pointercancel_event ---
当浏览器认为不再会有更多的指针事件, 或者在 {{event("pointerdown")}} 事件触发之后用户滚动或者缩放窗口,pointercancel
事件被触发。
Bubbles | Yes |
---|---|
Cancelable | No |
Interface | {{domxref("PointerEvent")}} |
Event handler property | onpointercancel |
常见需要 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'); };
Specification | Status |
---|---|
{{SpecName('Pointer Events', '#the-pointercancel-event')}} | {{Spec2('Pointer Events')}} |
{{Compat("api.HTMLElement.pointercancel_event")}}
onpointercancel
event handler propertyDocument
targets: pointercancel
event