// Apply a layout's position function to this collection's nodes with the standard layout options (spacingFactor, transform, fit/zoom/pan, animate) and the layoutstart/layoutready/layoutstop event flow
eles.layoutPositions(layout: object, options: LayoutBaseOptions, fn: (node: Collection<NodeData, EdgeData, Data>, i: number) => Position): thisApply a layout's position function to this collection's nodes with the standard layout options (spacingFactor, transform, fit/zoom/pan, animate) and the layoutstart/layoutready/layoutstop event flow. With animate: true the viewport animates concurrently (a fit targets the bounding box at the final positions).
| Name | Description |
|---|---|
layout: object | the layout instance the lifecycle events carry as |
options: LayoutBaseOptions | the standard layout options ( |
fn: (node: Collection<NodeData, EdgeData, Data>, i: number) => Position |
|
Fields of options
| 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 |
thisthis collection, for chaining
Example
cy.layout({ impl: { run(ctx) { ctx.eles.layoutPositions({}, { fit: false }, (node, i) => ({ x: i * 40, y: 0 }));} } }).run();console.log(cy.getElementById('b').position('x')); // 40