Skip to content

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

Open
jobo322 wants to merge 8 commits into
mainfrom
feat/brush-tracker-drag-events
Open

jobo322 wants to merge 8 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: 6229644
Status: ✅  Deploy successful!
Preview URL: https://dc46f20d.nmrium.pages.dev
Branch Preview URL: https://feat-brush-tracker-drag-even.nmrium.pages.dev

View logs

- 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.

@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

This branch has not been deployed

No deployments
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.

2 participants