synergycodes/ng-diagram/ng-diagram-resize-rotate-snap
Claude Code and agent skill by synergycodes/ng-diagram
- community
- ext:[{"type":"template","description":"Custom templates for code generation"}]
Checking that the SKILL.md file is still in the repository.
Use when making ng-diagram nodes resizable or rotatable (adornments, activeSides), setting a minimum size, snapping drag, resize or rotation to a grid, resizing, rotating or moving nodes from code, or when handles or settings seem ignored.
Install
npx vskill@latest install synergycodes/ng-diagram/ng-diagram-resize-rotate-snapSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
Resize, rotate and snap
Resize and rotate handles (adornments), their settings, minimum size, snapping of drag/resize/rotation, and the programmatic resizeNode/rotateNodeTo/moveNodesBy. Group-specific resize rules are in ng-diagram-groups; event payloads in ng-diagram-events.
Rules
- Custom templates get handles only through adornments. Wrap the content in
<ng-diagram-node-resize-adornment>and add<ng-diagram-node-rotate-adornment />next to it. Handles show only on the selected node. The default node has both; the default group template has the resize handles only. - Priority chain, highest first: the node's
resizable/rotatable→ the adornment's[defaultResizable]/[defaultRotatable]→ configresize.defaultResizable/nodeRotation.defaultRotatable(both defaulttrue). The first level that is set wins. "Config is ignored" almost always means a higher level is set. - A rotated node has no resize handles. The resize adornment hides while
angleis not 0. - Resizing writes `size` and needs `autoSize: false`. A resize gesture sets
autoSize: falseitself. ForresizeNodepassdisableAutoSize: true(4th argument), otherwise an auto-size node keeps its content size on screen. - Snapping is off by default. Each
shouldSnap…ForNodecallback returnsfalseuntil you replace it; the snap sizes alone do not snap anything (butdefaultDragSnap/computeSnapForNodeDragalso set the arrow-key step). - Type callback sections.
NgDiagramConfigdrops callback signatures: build each section with its own type (const snapping: Partial<SnappingConfig> = { ... }, likewisePartial<ResizeConfig>,Partial<NodeRotationConfig>), which types the parameters and checks the return type. Annotating parameters insidesatisfies NgDiagramConfigtypes only the body (ng-diagram-config). - Grid alignment: use multiples of the same step for
background.cellSizeand the snap sizes.
Resizable and rotatable custom node
activeSides(since 1.3.0, typeSide[]) limits which sides can be dragged. All four lines still render (they are the selection frame), but lines of sides left out are inert and show no resize cursor. A corner handle appears only when both of its sides are listed.[]keeps the frame without any resizing. The default node and group templates use all sides.- For a custom rotate handle, put your SVG or component inside
<ng-diagram-node-rotate-adornment>; empty content shows the built-in icon. - The resize adornment host is
position: relativeand fills the node, so ports placed inside it are positioned relative to the node box.
Resize and rotation config
getMinNodeSize(default 20×20) applies to resize gestures andresizeNode, and it is also set as CSSmin-width/min-heighton fixed-size nodes.resize.allowResizeBelowChildrenBoundsconcerns groups: seeng-diagram-groups.- Without rotation snapping, an angle within 2° of 0, 90, 180 or 270 snaps to it.
Snapping aligned with the grid
- Keys and defaults:
shouldSnapDragForNode/shouldSnapResizeForNode(() => false),computeSnapForNodeDrag/computeSnapForNodeSize/computeSnapOffsetForNodeSize(() => null, null falls back to the default),defaultDragSnapanddefaultResizeSnap({ width: 10, height: 10 }),defaultResizeSnapOffset({ width: 0, height: 0 }, since 1.3.0). The resize key iscomputeSnapForNodeSize; there is nocomputeSnapForNodeResize. - Drag snapping rounds the node position (top-left corner) to the step. Children of a dragged group move by the group's snapped delta and are not snapped on their own.
- Drag snapping also applies to palette drops and paste (since 1.2.0), arrow-key moves and
moveNodesBy— not toaddNodesorupdateNode. - Arrow keys move the selection by the drag snap step (
computeSnapForNodeDrag→defaultDragSnap, 10 px by default), also when drag snapping is off. - Resize snapping changes only the sides being dragged, keeps the opposite side in place, and then applies the minimum size.
- To switch snapping at runtime, call
NgDiagramService.updateConfig({ snapping: { shouldSnapDragForNode: () => true } })— the[config]binding is read only when the model is initialized. Or read a signal inside the callbacks: they run on every move and resize step.
Programmatic resize, rotate and move
resizeNode(id, size, position?, disableAutoSize?, options?): applies the minimum size, resize snapping and the group children rules. It does nothing when the size is unchanged (thenpositionanddisableAutoSizeare ignored too; useupdateNodeto move a node or to setautoSize: false), ignoresresizable, and resizes an unselected group since 1.3.0.optionsis{ waitForMeasurements?: boolean }(since 1.3.0). A node without anysizeonly gets the size, without minimum or snapping.rotateNodeTo(id, angle): normalizes to 0–360 and applies rotation snapping (or the 2° snap to right angles). It ignoresrotatable.moveNodesBy(nodes, delta)takes node objects, moves only those, and computes the new position from thepositionof the objects you pass. Pass fresh objects (getNodeById,getChildrenNested), not ones read from thenodes()/selection()signals right after another update. With drag snapping on, the target position is snapped, so a delta smaller than half a step does not move the node.- Programmatic calls fire
nodeResized,selectionRotatedandselectionMovedlike gestures do; the…Started/…Endedevents fire only for gestures. - For a hard limit during the gesture (not only after it), use a middleware (see
ng-diagram-middleware).
Events and cancel
- Resize:
nodeResizeStarted,nodeResized(on every change),nodeResizeEnded. Rotate:nodeRotateStarted,selectionRotated(on every change),nodeRotateEnded. The Started/Ended pairs exist since 1.1.0. - Escape (the
cancelInteractionshortcut) orNgDiagramService.cancelActiveInteraction()(both since 1.3.0) abort the gesture and restore the previous size, position andautoSize, or the previous angle.nodeResizeEnded/nodeRotateEndedthen carrycancelReason: 'cancelled'.
Styling the handles
- Resize handle:
--ngd-resize-handle-size,--ngd-resize-handle-background-color,--ngd-resize-handle-border-size,--ngd-resize-handle-border-style,--ngd-resize-handle-border-color,--ngd-resize-handle-border-radius. - Resize line:
--ngd-resize-line-border-width,--ngd-resize-line-border-style,--ngd-resize-line-border-color. - Rotate handle:
--ngd-rotate-handle-size,--ngd-rotate-handle-distance,--ngd-rotate-handle-background-color,-hover,-active, and the position variables--ngd-rotate-handle-top/-right/-bottom/-left. - The resizing docs page also lists
--ngd-resize-handle-background-color-hover/-activeand--ngd-resize-handle-top/-right/-bottom/-left; 1.4.0 does not read them.
Edge cases
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-resize-rotate-snap/SKILL.md
Popularity
- Repository stars
- 583
- Repository forks
- 41
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
templateCustom templates for code generation
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-resize-rotate-snap)