Skip to content

eles.move(opts)

eles.move — Collection > Graph manipulation. Cytoscape.js signatures, parameters and return contract.

eles.move — Collection › Graph manipulation

Preview · Collection › Graph manipulation

Read in the complete API reference · All API members

// Set a node's parent or an edge's endpoints without changing its id or data
eles.move(opts: { source?: string; target?: string; parent?: string | null; }): this

Set a node's parent or an edge's endpoints without changing its id or data.

Use { parent: id } to reparent nodes, or { parent: null } to make them orphans. Use { source: id, target: id } to rewire edges. If parent is present it takes precedence over endpoint keys. A changed parent emits a moveout event before the change and move afterwards.

An unknown parent is ignored. Cyclic parent assignments warn and are ignored.

Parameters
NameDescription
opts: { source?: string; target?: string; parent?: string | null; }

{ parent } to re-parent nodes (null orphans them), or { source, target } to re-point edges; parent wins if both are given

Fields of opts
NameDescription
source: string?
target: string?
parent: string | null?
Returns this

this collection, for chaining

Example

cy.getElementById('ab').move({ target: 'c' });
console.log(cy.getElementById('ab').target().id()); // 'c'

Example graph and handle setup