Skip to content
Back to skills

Ztx14 Best Pointer Capture Cancel Lifecycle

ASecurity

Make drag and press interactions robust to pointer leaving the target, browser cancellation, and interrupted device input.

  • 14 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 7, 2026
developmentapi

Works with

  • cursor
  • terminal
  • api

Security analysis

A100/100

Scanned November 7, 2026

npx -y skills add Realjustawall/Perfect-AI --skill ztx14-best-pointer-capture-cancel-lifecycle --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ztx14 Best Pointer Capture Cancel Lifecycle?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ztx14 Best Pointer Capture Cancel Lifecycle
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/realjustawall-ztx14-best-pointer-capture-cancel-lifecycle/badge)](https://www.skillsdirectory.com/skills/realjustawall-ztx14-best-pointer-capture-cancel-lifecycle)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ztx14-best-pointer-capture-cancel-lifecycle
description: Make drag and press interactions robust to pointer leaving the target, browser cancellation, and interrupted device input.
---

# Handle pointer capture, cancellation, and lost input

> Best-practice implementation skill. Inspect the real project, installed package versions, current component contract, and existing animation ownership before changing code. This skill adds guidance only; it does not install dependencies by itself.

## When to use
Dragging isometric objects, sliders, world panning, custom handles, and any interaction that spans beyond the initial hit target.

## Procedure
1. Use Pointer Events when the gesture should work consistently with mouse, touch, and pen.
2. On a valid pointerdown, record the pointerId and acquire pointer capture when needed so subsequent events keep reaching the gesture owner.
3. Handle `pointerup`, `pointercancel`, and `lostpointercapture` as distinct terminal paths; all must release temporary state and restore cursor/selection policies.
4. Ignore unrelated pointerIds or define explicitly whether multi-pointer input is supported.
5. Use `touch-action` narrowly; do not disable browser gestures at the whole-page level to make a component work.
6. Write end-to-end tests for leaving the element mid-drag, cancellation, route unmount, and a second pointer.

## Avoid
- Do not rely only on `pointerleave` to finalize a drag.
- Do not assume `pointerup` always occurs.
- Do not leave the UI in a pressed/dragging visual state after cancellation.

## Acceptance checks
- [ ] All terminal events reset state.
- [ ] A second gesture can start after cancel.
- [ ] Touch scrolling outside the intended drag area still behaves normally.

## Primary references
- https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events/Using_Pointer_Events
- https://developer.mozilla.org/en-US/docs/Web/API/Element/setPointerCapture
- https://developer.mozilla.org/en-US/docs/Web/API/Element/pointercancel_event

## Reporting requirement
State which files were inspected, what changed, and which checks actually ran. Do not claim a browser/device was verified unless it was tested.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.