Shumoku Docs

ドキュメントを検索

共通文書と現行公開版

検索を読み込み中…

English

@shumoku/core · 0.4.0 · function

placeNode

ソース

APIの説明は英語のcanonical sourceを表示しています。

**Geometric** placement for a single unpositioned node: find the point nearest `initial` that doesn't overlap any existing node or subgraph. The graph's link structure is deliberately ignored — this is the primitive for "drop the node exactly where the user clicked", "paste at cursor", "convert BOM item to diagram node at the canvas edge", i.e. user-driven placement where the surrounding topology should not influence the outcome. For **structural** placement (re-layout based on link flow, pin a set of nodes, arrange a selection), use `layoutNetwork` with its `fixed` / `hints` options instead. The two APIs stay separate because their intents differ: `placeNode` is O(existing obstacles) geometry, `layoutNetwork` is a full Sugiyama run.

placeNode(node: Node, graph: { nodes: Map<string, Node>; subgraphs?: Map<string, Subgraph> }, initial: { x: number; y: number }, gap?: number): { x: number; y: number }

パラメーター

名前 説明 既定値
node Node 追加説明はありません。
graph { nodes: Map<string, Node>; subgraphs?: Map<string, Subgraph> } 追加説明はありません。
initial { x: number; y: number } 追加説明はありません。
gap number 追加説明はありません。 DEFAULT_NODE_GAP

戻り値

{ x: number; y: number }

libs/@shumoku/core/src/layout/interaction.ts:137