Document: gotpointercapture event
The gotpointercapture
event is fired when an element captures a pointer using setPointerCapture()
.
Bubbles | No |
---|---|
Cancelable | No |
Interface | PointerEvent |
Event handler property | ongotpointercapture |
Examples
This example gets a <p>
element and listens for the gotpointercapture
event. It then calls setPointerCapture()
on the element on a pointerdown
event, which will trigger gotpointercapture
.
const para = document.querySelector('p');
document.addEventListener('gotpointercapture', () => {
console.log('I\'ve been captured!')
});
para.addEventListener('pointerdown', (event) => {
para.setPointerCapture(event.pointerId);
});
The same example, using the ongotpointercapture
event handler property:
const para = document.querySelector('p');
document.ongotpointercapture = () => {
console.log('I\'ve been captured!')
};
para.addEventListener('pointerdown', (event) => {
para.setPointerCapture(event.pointerId);
});
Specifications
Specification |
---|
Pointer Events # the-gotpointercapture-event |
Browser compatibility
BCD tables only load in the browser
See also
- Related events
ongotpointercapture
event handler property- This event on
HTMLElement
targets:gotpointercapture
event