revision:
The releasePointerCapture() method of the Element interface releases (stops) pointer capture that was previously set for a specific (PointerEvent) pointer.
releasePointerCapture(pointerId)
Parameters:
pointerId : The pointerId of a PointerEvent object.
<div> <div id="slider">SLIDE ME</div> </div> <style> div #slider{width: 14vw; height: 5vw; display: flex; align-items: center; justify-content: center; background: #fbe;} </style> <script> 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; </script>