synergycodes/ng-diagram/ng-diagram-touch
Claude Code and agent skill by synergycodes/ng-diagram
- community
Checking that the SKILL.md file is still in the repository.
Use when an ng-diagram app must work on phones or tablets - pinch zoom, two-finger pan, long-press box selection, drawing edges by finger, an on-screen editing toolbar, or touch bugs (inputs in nodes, cancelled draws, palette on iPad).
Install
npx vskill@latest install synergycodes/ng-diagram/ng-diagram-touchSKILL.md
Touch and Mobile
How ng-diagram behaves on touch screens, what you must build yourself (buttons for actions that have no gesture), and the touch-specific edge cases. Linking details are in ng-diagram-linking, selection and clipboard in ng-diagram-selection-clipboard, the palette in ng-diagram-palette.
Rules
- Touch support is built in.
<ng-diagram>handles touch and pointer events itself, so do not add your own touch listeners for pan, zoom, select or drag, and do not override itstouch-action: none- the library relies on it to stop the browser from scrolling or zooming the page during a gesture. - Copy, cut, paste, delete, undo and redo have no touch gesture, and neither has "add to selection" (the
multiSelectionbinding needs a modifier key). Give touch users on-screen buttons that call the services. - One finger never pans the canvas. Panning and pinch zoom use two fingers; a one-finger swipe on empty canvas only clears the selection.
- Put
data-no-drag="true"on inputs, buttons and other interactive elements inside node templates, or a finger on them drags the node. The value must be the string"true".data-no-pan="true"keeps a pan from starting on the element (seeng-diagram-custom-nodes). - Call
NgDiagramService.startLinkingfrom a(click)handler. On touch the draw follows the finger and ends on the next finger lift anywhere on the page, so starting it onpointerdown/touchstartends it on the same lift. - Every mutating service method returns a Promise (since 1.3.0):
awaitit when the next line depends on the result, otherwisevoidit.
Gesture map
| Gesture | Result | |
|---|---|---|
| Tap a node or an edge | Selects it. Tapping a node that is already selected keeps the whole selection, so one finger can then drag a multi-selection. | |
| Tap or swipe on empty canvas | Clears the selection. No pan. | |
| One-finger drag on a node | Moves the node (or the selection). Respects nodeDraggingEnabled and the node's draggable. | |
| Long press (hold 400 ms, moving 10 px or less), then drag | Box selection. Uses the boxSelection config (partialInclusion, realtime). The Shift binding is desktop only. | |
| Two fingers moving together | Pans. Needs viewportPanningEnabled (default true); does not start when the touch begins on a data-no-pan="true" element. | |
| Two-finger pinch | Zooms around the point between the fingers, once the finger distance has changed by more than 40 px. Clamped to zoom.min/zoom.max. | |
| Drag a resize or rotate handle of a selected node | Resizes or rotates the node. | |
| Drag from a port, lift over another port | Draws an edge (see ng-diagram-linking). | |
| Drag a handle at the end of a selected edge | Relinks that end (since 1.4.0, see ng-diagram-edge-relinking). The handle's grab area stays 24 px wide on screen at every zoom level. | |
| Drag a palette item, lift over the diagram | Drops a node where the finger lifts (see ng-diagram-palette). |
Gesture priority
- Two fingers win. A two-finger pan or pinch ends any one-finger gesture: a drag, resize or rotation stops where it is and is kept (its
*Endedevent has nocancelReason); an edge draw started from a port, or a relink, is cancelled (reason: 'cancelled'). A programmatic draw is not (see Edge cases). - In one two-finger gesture, a pinch replaces the pan as soon as the finger distance changes by more than 40 px, and the pan does not come back until the fingers lift.
- Resize, rotate and drawing from a port block the long-press box selection.
- The long-press timer runs for every one-finger touch in the diagram, also on a node. Unless the finger moves more than 10 px within 400 ms, box selection starts and ends the node drag, so move right away to drag a node.
On-screen editing toolbar
Render the toolbar inside the component that declares provideNgDiagram(), so it gets the same service instances as the diagram (see ng-diagram-setup).
paste(position) places the content at position (flow coordinates): one node is centered on it, several nodes land about half a node right and down of it (exact rule in ng-diagram-selection-clipboard). For undo/redo, implement undo()/redo() in a custom ModelAdapter (see ng-diagram-persistence). To add nodes to the selection from your own UI, pass the full list: select(ids) replaces the current selection.
Connect button (programmatic linking)
Port dots are small for a finger. A "Connect" button starts a draw from the selected node; the user then puts a finger on empty canvas, slides to the target port and lifts. A touch that starts on a node also selects and drags that node.
- After
startLinking(node, portId?), the edge follows the next one-finger move. The lift ends the draw: over a port that accepts the edge it connects; anywhere else it ends withreason: 'noTarget', or, withdanglingEdges.enabled, keeps a dangling edge (seeng-diagram-dangling-edges). - The target is the port nearest to the last finger position, so a tap without moving connects nothing. The finger has to move onto the port.
startLinkingis ignored (with a console warning) while another draw or relink is active, or when the node is missing or hidden. A port of type'target', a hidden port, or a port id the node does not have is refused silently (no warning, noedgeDrawEnded).startLinkingFromPosition(position)(since 1.4.0) draws from a canvas point the same way and needsdanglingEdges.enabled.edgeDrawEndedexists since 1.2.0 and its'cancelled'reason since 1.3.0.
Finger-friendly targets
Default targets are small for a finger. A default port and a resize corner have fixed invisible hit circles of 18 px and 16 px; the size variables grow the visible shape, and the target grows only when that shape is bigger than the circle. Both live inside the diagram, so they also shrink when the user zooms out. Relink handles always have a 24 px grab circle on screen. For targets of about 32 px at zoom 1, and a draw that snaps to ports from further away:
These values also make the shapes big. For a big target with a small look, use custom port content (see ng-diagram-ports); for theming, ng-diagram-styling.
Edge cases
- There is no
stopLinkingmethod, although the 1.0.0 changelog lists one; no release exports it. To abort a draw from code, callcancelActiveInteraction()(since 1.3.0, returnsPromise<boolean>). It is refused with a console warning while a transaction is active. - During a programmatic draw on touch, the next lift anywhere on the page ends the draw, and that touch produces no
click(the library cancels thetouchend). A "Cancel" button tapped mid-draw therefore only ends the draw (asnoTarget, or as a dangling edge when dangling edges are on). Use(pointerdown)withcancelActiveInteraction()for a Cancel button (recipe above). A two-finger pan or pinch does not cancel a programmatic draw; the draw ends when a finger lifts. Pan and zoom before tapping "Connect". - A swipe that starts on the diagram never scrolls the page (
touch-action: none). On a phone, leave some page area outside the diagram, or size the diagram to the screen. - A swipe that starts on a palette item starts a palette drag and does not scroll the palette list (the item cancels its
touchstart). The preview drag image is built only for HTML5 drags (dragstart); the touch path just drops the node where the finger lifts. - The library has no double-tap gesture and no long-press menu. If you add your own long-press handling, remember that holding still for 400 ms starts box selection.
- No config flag turns pinch zoom off; it is only clamped by
zoom.min/zoom.max.viewportPanningEnabled: falseturns off two-finger pan (and desktop pan). - Laptop trackpads send wheel events, not touch events: a two-finger scroll pans and a pinch zooms (since 1.2.4 a pinch zooms whatever the
zoomshortcut binding is);Shift+ scroll pans sideways. Seeng-diagram-viewportandng-diagram-shortcuts.
Symptom → fix
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/ng-diagram-touch/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/synergycodes/ng-diagram/ng-diagram-touch)