# Passive Event Listeners and Compositor Scrolling vs Pointer Events, touch-action, and Pointer Capture

- **Canonical URL:** https://frontend.rocks/vs/passive-event-listeners-vs-pointer-events-touch-action/
- **Relation:** Contrasts With
- **Last Verified:** 2026-11-15
- **Verdict:** Passive listeners promise no preventDefault() in JS, whereas CSS touch-action declares scroll constraints to the compositor.

## Comparison Matrix

| Dimension | Passive Event Listeners and Compositor Scrolling | Pointer Events, touch-action, and Pointer Capture |
| :--- | :--- | :--- |
| **Maturity** | Baseline · Widely | Baseline · Widely |
| **Domain** | DOM & Events | DOM & Events |
| **Mental Model** | Eliminate 100ms+ mobile scroll-start jank—{ passive: true } promises the GPU compositor thread that wheel/touch listeners will never call preventDefault(). | Stop mobile browser scroll from hijacking custom drags and sliders—CSS touch-action negotiates gesture ownership on the compositor while setPointerCapture() locks fast pointer streams. |
| **Prerequisites** | DOM Event Propagation (Capture, Target, Bubble) (Passive flags are checked during hit-testing before dispatching wheel or touch propagation.) | DOM Event Propagation (Capture, Target, Bubble) (Pointer events follow standard capture/target/bubble propagation unless redirected by setPointerCapture().); Passive Event Listeners and Compositor Scrolling (CSS touch-action negotiates scroll ownership on the compositor without blocking passive listeners.) |
| **When Not to Use** | When not to use { passive: false }: Avoid { passive: false } on general page wrappers just to suppress scroll conditionally; use CSS touch-action via Pointer Events & touch-action instead. | When not to use touch-action: none: Never apply touch-action: none to large scrollable sections, it traps mobile users who try to scroll past the widget. |

## Passive Event Listeners and Compositor Scrolling — Under the Hood
The compositor thread checks a hit-tested layer's non-passive event region bit before translating a scroll gesture; if any non-passive `touchstart` or `wheel` listener is present, scrolling stalls until main-thread JS finishes. Passing `{ passive: true }` gives the compositor permanent clearance to translate the layer immediately at 120 fps.

1. **Non-Passive Slow Path**: The compositor checks a "slow scroll region" bit; if present, it waits for main-thread JS to finish running the listener before scrolling.
2. **Passive Fast Path**: The compositor translates the layer immediately and dispatches the event asynchronously.
3. **Root Default**: Chrome, Firefox, and Safari default `touchstart`, `touchmove`, and `wheel` on `window`, `document`, and `body` to `passive: true`.

```js
// Analytics listener: never blocks compositor scroll
scroller.addEventListener('wheel', recordScrollDelta, { passive: true });

// Custom zoomable map: explicitly opt out of passive
mapCanvas.addEventListener('wheel', (e) => {
  e.preventDefault();
  zoomMap(e.deltaY);
}, { passive: false });
```

## Pointer Events, touch-action, and Pointer Capture — Under the Hood
At `touchstart`, the compositor thread reads CSS `touch-action` off the hit-tested layer to decide whether native pan/zoom owns the gesture without waiting for main-thread JS. Like painting dedicated bike lanes before rush hour, `touch-action: none` reserves the stream for your drag handler so the browser never fires `pointercancel` mid-drag.

1. **Compositor Pre-Check**: At `touchstart`, the compositor reads `touch-action` (`none`, `pan-x`, `pan-y`, `manipulation`) without waiting for JS.
2. **No `pointercancel`**: On `touch-action: none`, the browser suppresses native pan/zoom so `pointermove` streams cleanly.
3. **Pointer Capture**: Calling `el.setPointerCapture(e.pointerId)` redirects all subsequent [DOM Event Propagation](/concepts/dom-event-propagation) for that pointer straight to `el` until `pointerup`.

```js
knob.addEventListener('pointerdown', (e) => {
  knob.setPointerCapture(e.pointerId);
  knob.dataset.dragging = 'true';
});
knob.addEventListener('pointermove', (e) => {
  if (knob.dataset.dragging === 'true') moveKnob(e.clientX);
});
knob.addEventListener('pointerup', () => delete knob.dataset.dragging);
```

## Interactive Labs & Dissections
- [Passive Event Listeners and Compositor Scrolling Lab](https://frontend.rocks/concepts/passive-event-listeners/#lab) ([Markdown](https://frontend.rocks/concepts/passive-event-listeners.md))
- [Pointer Events, touch-action, and Pointer Capture Lab](https://frontend.rocks/concepts/pointer-events-touch-action/#lab) ([Markdown](https://frontend.rocks/concepts/pointer-events-touch-action.md))

## Related Architecture Autopsies
- [Autopsy #07: Green CI, Broken Prod: What JSDOM Hid From Your Tests](https://frontend.rocks/autopsies/green-ci-broken-prod-jsdom/) ([Markdown](https://frontend.rocks/autopsies/green-ci-broken-prod-jsdom.md)): 100% of unit and component tests pass in CI while the mobile navigation dropdown is completely unclickable in production.

## Primary Sources
- https://dom.spec.whatwg.org/#dom-addeventlisteneroptions-passive
- https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#passive
- https://w3c.github.io/pointerevents/#the-touch-action-css-property
- https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events
