The lostpointercapture event fires when a captured pointer is released. Learn addEventListener vs onlostpointercapture, pointerId, the gotpointercapture pair, releasePointerCapture(), drag cleanup patterns, and five try-it labs.
01
Kind
Instance event
02
Type
PointerEvent
03
When
Capture released
04
Handler
onlostpointercapture
05
Pair
gotpointercapture
06
Status
Baseline widely available
Fundamentals
Introduction
Pointer capture lets an element keep receiving events for a specific pointer even when the pointer leaves that element’s hit area—perfect for sliders, drag handles, and canvas drawing.
When capture ends, the browser fires lostpointercapture on the element that had captured the pointer. That is your cue to leave “dragging” mode: clear classes, reset cursors, and stop treating moves as part of the session.
💡
Beginner tip
Capture usually starts with setPointerCapture(pointerId) inside pointerdown. Capture ends when you call releasePointerCapture(pointerId), or when the pointer goes up / cancels. Always pair gotpointercapture (start) with lostpointercapture (end) for reliable UI state.
Concept
Understanding lostpointercapture
An instance event that answers: “Did this element just lose pointer capture?”
Fires when a previously captured pointer is released.
PointerEvent — includes pointerId, pointerType, and more.
Handler — onlostpointercapture or addEventListener("lostpointercapture", ...).
Pair — gotpointercapture when capture begins.
Related APIs — setPointerCapture, releasePointerCapture, hasPointerCapture.
Baseline Widely available on MDN (since July 2020).
Foundation
📝 Syntax
Use the event name with addEventListener, or set the handler property:
Pressing starts capture; lifting the pointer ends it and fires lostpointercapture. Without an earlier setPointerCapture, this listener will not run from a normal click.
Example 2 — onlostpointercapture Property (MDN)
Same idea using the handler property form.
JavaScript
const para = document.querySelector("p");
const out = document.getElementById("out");
para.onlostpointercapture = () => {
out.textContent = "I've been released!";
};
para.addEventListener("pointerdown", (event) => {
para.setPointerCapture(event.pointerId);
});
lostpointercapture is marked Baseline Widely available on MDN (since July 2020). Logos use the shared browser-image-sprite.png sprite from this project. Pointer capture is part of the modern Pointer Events model across engines.
✓ Baseline · Widely available
Element lostpointercapture
Fires when a captured pointer is released; pair with gotpointercapture for drag sessions.
FullWidely available
Google Chrome57+
Yes
Mozilla Firefox59+
Yes
Apple Safari13+
Yes
Microsoft Edge17+
Yes
Opera44+
Yes
Internet ExplorerNo modern Pointer Events
No
lostpointercaptureBaseline
Bottom line: Safe to use for modern drag UX cleanup. Always handle release and cancel paths, and test touch + mouse.
Wrap Up
Conclusion
lostpointercapture tells you that pointer capture has ended. Use it to leave a drag session cleanly after gotpointercapture started it.
Listen for gotpointercapture / lostpointercapture as a pair
Clean up UI and flags inside lostpointercapture
Use hasPointerCapture before calling releasePointerCapture
Handle both pointerup and cancel / early-release paths
Prefer addEventListener for production code
❌ Don’t
Leave drag classes on forever because you only handled pointerup
Ignore multi-touch pointerId matching when cleaning up
Forget pointercancel can also end capture
Overwrite onlostpointercapture if you need multiple listeners
Assume capture without an earlier successful setPointerCapture
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about lostpointercapture
Capture ended—clean up the drag session.
5
Core concepts
📱01
On release
capture ended
Trigger
📄02
PointerEvent
pointerId · type
API
👆03
Cleanup UX
reset drag UI
Why
🔄04
gotpointercapture
session opened
Pair
🎯05
Baseline
widely available
Status
❓ Frequently Asked Questions
It fires when a captured pointer is released. Capture can end via releasePointerCapture(), pointerup, pointercancel, or other release paths. Use it to clean up drag UI and session state.
No. MDN marks Element lostpointercapture as Baseline Widely available. It is not Deprecated, Experimental, or Non-standard.
A PointerEvent (inherits from MouseEvent and Event). Handy fields include pointerId, pointerType, and isPrimary.
After pointer capture ends for that element — for example when you call releasePointerCapture(pointerId), or when the pointer is released (pointerup) while capture was active.
gotpointercapture fires when setPointerCapture() succeeds and capture begins. lostpointercapture is the matching end signal.
So you can reset cursors, remove dragging classes, stop tracking moves, and restore idle UI when the capture session ends — even if the pointer left the element.
Did you know?
You can end capture early with releasePointerCapture() even while the pointer is still down. The browser still fires lostpointercapture, so your cleanup path stays in one place.