Skip to content

fix(core): arm doubleClickDragZoom by coordinating the dblclickdrag recognizer - #10418

Merged
charlieforward9 merged 1 commit into
x/mjolnir-upfrom
fix/doubleclickdrag-recognizer
Jul 3, 2026
Merged

charlieforward9 merged 1 commit into
x/mjolnir-upfrom
fix/doubleclickdrag-recognizer

Conversation

@charlieforward9

Copy link
Copy Markdown
Member

Problem

doubleClickDragZoom (added in #10327, enabled by the mjolnir.js 3.0.1 upgrade in this PR) never fires — a double-click-drag silently pans instead of zooming.

Cause

dblclickdrag was registered in RECOGNIZERS with no recognizeWith relationship. mjolnir's manager calls reset() on any non-active recognizer that can't recognize-with the currently active one. So the moment click/dblclick activate during the first tap, DoubleClickDrag's cross-tap memory (_lastTap) is wiped before the pointer-up is even processed. The second press then never matches a prior tap, the gesture never arms, and the drag falls through to pan.

Fix

Register dblclickdrag to recognize simultaneously with click/dblclick. Its tap memory survives the first tap; it then becomes the active recognizer on the second press, which also suppresses the competing pan (no zoom+pan jitter).

Verification (headless pointer input)

  • Double-click-drag up → zooms 4.0 → 5.2, latitude drifts only monotonically (anchored-zoom pivot), no pan sawtooth.
  • Plain drag → still pans (lng changes, zoom unchanged).
  • Plain double-click → still zooms in one step.

cc @Pessimistress

🤖 Generated with Claude Code

…blclick

The DoubleClickDrag recognizer was registered with no recognizeWith
relationship, so mjolnir's manager called reset() on it as soon as the
click/dblclick recognizers activated during the first tap. That wiped its
cross-tap memory (_lastTap) before the pointer-up was processed, so the
second press never matched a prior tap and the gesture never armed --
doubleClickDragZoom silently fell through to pan.

Registering it to recognize simultaneously with click/dblclick keeps its
tap memory intact; it then becomes the active recognizer on the second
press, which also suppresses the competing pan (no more zoom+pan jitter).

Verified end-to-end via headless input: double-click-drag now zooms with
no pan drift, while plain drag still pans and plain double-click still
zooms one step.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@charlieforward9
charlieforward9 force-pushed the fix/doubleclickdrag-recognizer branch from 2453242 to bd9a266 Compare July 3, 2026 19:34
@charlieforward9
charlieforward9 merged commit afeb3d8 into x/mjolnir-up Jul 3, 2026
3 checks passed
@charlieforward9
charlieforward9 deleted the fix/doubleclickdrag-recognizer branch July 3, 2026 19:35
@charlieforward9 charlieforward9 self-assigned this Jul 3, 2026
@coveralls

coveralls commented Jul 3, 2026 •

Copy link
Copy Markdown

Coverage Status

Coverage is 83.136% — fix/doubleclickdrag-recognizer into x/mjolnir-up. No base build found for x/mjolnir-up.

chrisgervang added a commit that referenced this pull request Jul 10, 2026
* upgrade mjolnir.js

* fix(core): register dblclickdrag recognizer to recognize with click/dblclick (#10418)

Co-authored-by: Claude Opus 4.8 <[email protected]>

* fix(core): eliminate 300ms click delay and fix runtime controller prop changes (#10422)

* fix(core): disable doubleClickZoom by default to eliminate 300ms click delay

The click recognizer's requireFailure dependency on dblclick causes
mjolnir.js to defer click events by 300ms. Disabling doubleClickZoom
by default removes this delay while keeping doubleClickDragZoom
available for zoom-by-drag gestures.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(core): also disable doubleClickDragZoom by default

Same principle — once #10416 lands, dblclickdrag should be in click's
requireFailure list to prevent spurious clicks before a drag-zoom.
That would reintroduce the 300ms delay, so disable by default too.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(core): add dblclickdrag to click's requireFailure list

Prevents spurious click events from firing before a double-click-drag
zoom gesture is recognized. Without this, a click would emit on the
first tap before the recognizer determines the user intends to drag.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* test(core): add click delay unit tests for controller gesture config

Tests verify through the full EventManager → recognizer pipeline that:
- Click fires immediately when doubleClickZoom and doubleClickDragZoom
  are both disabled (the new default)
- Click is delayed ~300ms when doubleClickZoom is enabled
- Click is delayed ~300ms when doubleClickDragZoom is enabled

Also reorders RECOGNIZERS so dblclickdrag is registered before click,
which is required for click's requireFailure reference to resolve.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(core): ensure dblclick recognizer is disabled when doubleClickZoom is false

The dblclick/dblclickdrag recognizers start with enable:false so they don't
cause the 300ms click delay out of the box. Deck's picking system uses watch()
(passive) for the dblclick event so it doesn't force-enable the recognizer.
Only the controller's doubleClickZoom option enables it.

Also adds integration tests that verify click latency at the Deck level using
real pointer events dispatched to the canvas.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* test(core): fix dblclick integration tests using direct pointer dispatch

The dblclick tests were broken because page.mouse.dblclick() doesn't
properly target the canvas inside vitest's browser iframe. Fixed by
dispatching PointerEvents directly on the canvas element, matching how
mjolnir's PointerEventInput listener works (pointerdown on element,
pointerup on window). Each test uses a fresh Deck instance for isolation.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(core): propagate runtime controller prop changes to ViewManager

Deck._getViews() was mutating the View instance's props.controller in-place,
so ViewManager._diffViews short-circuited on identity (same object) and never
triggered _rebuildViewports. Controller option changes via setProps had no
effect at runtime. Fixed by cloning the view when applying the controller prop.

Also adds a gesture-timing test app that measures event handling delays and
demonstrates the ~300ms click latency tradeoff with doubleClickZoom.

- Restore doubleClickZoom=true default (breaking change avoidance)
- Add regression test for runtime controller prop propagation
- Add test/apps/gesture-timing for interactive delay measurement

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>

* docs(core): document onClick(tapCount=2) side-effect of doubleClickZoom

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Charles Richardson <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
Co-authored-by: Chris Gervang <[email protected]>
Co-authored-by: Chris Gervang <[email protected]>
@chrisgervang chrisgervang added this to the v9.4 milestone Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants