Baseline Widely available
The releasePointerCapture()
method of the Element
interface releases (stops) pointer capture that was previously set for a specific (PointerEvent
) pointer.
releasePointerCapture(pointerId)
Parameters Return value
None (undefined
).
NotFoundError
DOMException
Thrown if pointerId
does not match any active pointer.
This example sets pointer capture on a <div>
when you press down on it. This lets you slide the element horizontally, even when your pointer moves outside of its boundaries.
<div id="slider">SLIDE ME</div>
CSS
div {
width: 140px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
background: #fbe;
}
JavaScript
function beginSliding(e) {
slider.onpointermove = slide;
slider.setPointerCapture(e.pointerId);
}
function stopSliding(e) {
slider.onpointermove = null;
slider.releasePointerCapture(e.pointerId);
}
function slide(e) {
slider.style.transform = `translate(${e.clientX - 70}px)`;
}
const slider = document.getElementById("slider");
slider.onpointerdown = beginSliding;
slider.onpointerup = stopSliding;
Result Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3