Skip to content

feat: add drag and drag-end events to BrushTracker - #4413

Merged
jobo322 merged 20 commits into
mainfrom
feat/brush-tracker-drag-events
Nov 10, 2026
Merged

jobo322 merged 20 commits into
mainfrom
feat/brush-tracker-drag-events

Conversation

@jobo322

@jobo322 jobo322 commented Oct 16, 2026

Copy link
Copy Markdown
Member

feat: add drag and drag-end events to BrushTracker

Adds onDrag / onDragEnd events to the BrushTracker gesture pipeline so plugin chart slots can implement anchor dragging through the tracker event API instead of local DOM overlays.

Scope and backward compatibility

This change is additive and does not modify the legacy filters pipeline:

  • Legacy filter anchors are untouched. The diff includes no changes to BaselinePreview, the legacy Anchor element, or any filters-panel code; the legacy baseline correction flow keeps its own drag implementation, which never uses the new events.
  • BrushTracker is shared by the whole chart, but its behavior is unchanged for consumers that do not claim a drag. The drag/drag-end events are always emitted, but emitting to zero listeners is a no-op; the brush dispatch happens exactly as before unless a drag listener claims the gesture (stopPropagation). Verified at the edges too: gestures without a drag gesture controller (e.g. middle button) and ctrl+zoom behave identically to the previous implementation.
  • The onChange prop on the operator ChartSVG slot is additive. It is threaded through the host for all operators, but only the baseline correction operator defines a ChartSVG and uses it (keyboard anchor deletion); the other operators are unaffected.

The only functional consumer of the new API is the baseline correction operator UI in the new pipeline of processors

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Deploying nmrium with  Cloudflare Pages  Cloudflare Pages

Latest commit: 165cbef
Status: ✅  Deploy successful!
Preview URL: https://084515fa.nmrium.pages.dev
Branch Preview URL: https://feat-brush-tracker-drag-even.nmrium.pages.dev

View logs

@tpoisseau tpoisseau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@jobo322
jobo322 force-pushed the feat/brush-tracker-drag-events branch from e066211 to 6229644 Compare October 20, 2026 19:24
@jobo322
jobo322 force-pushed the feat/brush-tracker-drag-events branch 2 times, most recently from f31d2ff to c0b91e5 Compare November 6, 2026 16:16
jobo322 and others added 14 commits November 10, 2026 09:25
- Extend BrushTrackerProps with onDrag/onDragEnd and a DragTrackerEvent
  payload (chart-relative coordinates, start position, mouse button,
  modifier keys, domEvent and a gesture claim API).
- Extend the emitter union with 'drag' | 'drag-end'.
- Emit drag from the first pointermove with a pressed button (no
  threshold) and on every move; a consumer claim (stopPropagation)
  suppresses the brush dispatch for the rest of the gesture.
- Extract the gesture logic to brush_tracker_drag_gesture.ts with unit
  tests.
- Thread onChange to the operator ChartSVG slot so SVG-layer
  interactions (keyboard anchor deletion) can update the operation.
The tracker events exposed the raw shiftKey, so operator UIs had to hard-code shift and could not follow the general.invert preference. Resolve the primary key with useMapKeyModifiers in the chart brush commons, pass it to the click and drag events, and make the default brush of the zoom tool follow the primary key too.
The zoom tool region brush followed the raw shiftKey. With the default general.invert=true the plain drag activates the primary key, so the brush must be enabled when isPrimary is true, consistent with the other tools' actions.
@hamed-musallam
hamed-musallam force-pushed the feat/brush-tracker-drag-events branch from c0b91e5 to c385030 Compare November 10, 2026 08:28
- Override typescript-eslint to 8.71.0 to avoid false link deprecations
- Preserve inset scroll delta fallback while satisfying lint
- Update package lockfile
Comment thread package.json Resolved
Comment thread eslint.config.js Resolved
@hamed-musallam

hamed-musallam commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

We can discuss this ESLint problem in another issue based on Michael's suggestion; I already opened one #4431, @jobo322, can you proceed and merge this PR unless you still need to add more changes?

@jobo322
jobo322 merged commit 7fe002a into main Nov 10, 2026
12 checks passed
@jobo322
jobo322 deleted the feat/brush-tracker-drag-events branch November 10, 2026 13:44
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.

4 participants