// The discrete layout finisher over the scope — spacingFactor, transform, animate (with the fit-at-final-positions viewport animation), fit/zoom/pan, and the layoutready/layoutstop events
ctx.layoutPositions(fn: (node: Collection, i: number) => Position, overrides?: LayoutBaseOptions): voidThe discrete layout finisher over the scope — spacingFactor, transform, animate (with the fit-at-final-positions viewport animation), fit/zoom/pan, and the layoutready/layoutstop events. The wrapper's layoutstart covers the start (no double emit).
| Name | Description |
|---|---|
fn: (node: Collection, i: number) => Position | called per scoped node with the node and its index, returning the model position to place it at |
overrides: LayoutBaseOptions?Default: {} | an impl's own defaults, merged over the run's options Shared options apply consistently to built-in and custom layouts. |
Fields of overrides
| Name | Description |
|---|---|
eles: unknown? | the elements to lay out (set automatically by |
fit: boolean? | |
padding: number? | |
boundingBox: BoundingBoxInput? | |
nodeDimensionsIncludeLabels: boolean? | include labels in the node dimensions a layout spaces by — default
|
spacingFactor: number? | |
transform: (node: unknown, position: Position) => Position? | transform a computed position (e.g. to flip an axis) |
animate: boolean? | whether to animate node positions into place |
animationDuration: number? | |
animationEasing: string? | |
animateFilter: (node: unknown, i: number) => boolean? | which nodes animate (others jump); all by default |
ready: () => void? | callback on layoutready |
stop: () => void? | callback on layoutstop |
zoom: number? | zoom to set when fit is false |
pan: Position? | pan to set when fit is false |
voidExample
// Inside a custom layout, ctx is supplied by the library.cy.layout({ impl: { run(ctx) { ctx.layoutPositions((node, i) => ({ x: i * 40, y: 0 }), { fit: false });} } }).run();console.log(cy.getElementById('b').position('x')); // 40