feat(joint-core): add Paper#setDragging / Paper#isDragging API#3321
Merged
Geliogabalus merged 4 commits intoMay 19, 2026
Merged
Conversation
New public methods on `dia.Paper` for marking and reading the active-drag state on an event:
- `paper.setDragging(evt, value = true)` — stash the drag flag on the event's per-paper `eventData` bag (defaults to `true`).
- `paper.isDragging(evt)` — boolean read of the same flag.
Joint-core itself sets the flag from every action-confirmed drag-start branch:
- `ElementView.dragStart` — element move (after `can('elementMove')`).
- `LinkView.dragStart` — link move (after `can('linkMove')`).
- `LinkView.dragLabelStart` — label move (inside `can('labelMove')` block).
- `LinkView.dragArrowheadStart` — arrowhead move (after `can('arrowheadMove')`).
- `CellView.dragLinkStart` — magnet→link transition (when the link is actually created, which may be deferred under `magnetThreshold: 'onleave'`).
External consumers (plugins / hosts) can now ask "is a drag actually happening?" without inspecting view-level eventData internals. Useful for capture-on-drag, custom cursors, drag-aware UI overlays, etc.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Always sets to true. The optional value parameter was unused code for a hypothetical reset use case. YAGNI — easy to add later if needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds a QUnit module that verifies:
- direct API round-trip (set then read);
- `isDragging` defaults to false on fresh events;
- `ElementView.dragStart` flips the flag after `can('elementMove')` passes;
- `isDragging` stays false when `elementMove` is denied;
- `LinkView.dragStart` flips the flag after `can('linkMove')`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ging signatures `dia.Event` was unresolved inside dia.d.ts itself; the file declares `export type Event = mvc.TriggeredEvent` and other methods reference `Event` directly. Match the convention. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Geliogabalus
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two public methods on
dia.Paperfor marking and reading the active-drag state on an event:paper.setDragging(evt, value = true)— stash the drag flag on the event's per-papereventDatabag (defaults totrue).paper.isDragging(evt)— boolean read of the same flag.Joint-core itself sets the flag from every action-confirmed drag-start branch:
dia/ElementView.mjsdragStartcan('elementMove')dia/LinkView.mjsdragStartcan('linkMove')dia/LinkView.mjsdragLabelStartcan('labelMove')blockdia/LinkView.mjsdragArrowheadStartcan('arrowheadMove')dia/CellView.mjsdragLinkStartThe magnet path notably waits until
CellView.dragLinkStartruns (which may be deferred undermagnetThreshold: 'onleave'), so a magnet pointerdown alone doesn't trip the flag — only when the link actually starts.Motivation
External consumers (plugins, embedding hosts) currently have to inspect view-level
eventData(action,linkView, etc) to determine whether a drag is actually in progress, which means leaking joint-core internals across the API boundary. With these two methods, the question "is a drag actually happening?" becomes a one-call public API.Use cases:
setPointerCaptureonly after a drag is confirmed — i.e. not on every pointerdown).pointermoveand want to gate their work on real drag state.A follow-up PR in
@joint/reactuses this API to drivesetPointerCapture+ ajj-is-draggingCSS class.Changes
packages/joint-core/src/dia/Paper.mjs— definesetDraggingandisDragging.packages/joint-core/src/dia/ElementView.mjs— callpaper.setDragging(evt)aftercan('elementMove').packages/joint-core/src/dia/LinkView.mjs— callpaper.setDragging(evt)indragStart,dragLabelStart,dragArrowheadStart.packages/joint-core/src/dia/CellView.mjs— callpaper.setDragging(evt)at the end ofdragLinkStart.packages/joint-core/types/dia.d.ts— declarations for both methods.Test plan
yarn workspace @joint/core test— full QUnit suite (server + client).grunt test:server --file=test/jointjs/paper.js— Paper-specific.paper.on('pointermove', evt => console.log(paper.isDragging(evt)))— expecttrueonly after a drag-start gate has passed (drag the element / link / label / arrowhead, or magnet-to-link).🤖 Generated with Claude Code