#ele.position()
// Get the position
ele.position(): Position | undefinedRead the first element's position in model coordinates.
Position | undefinedthe first element's position, or undefined when empty
Example
console.log(cy.getElementById('a').position()); // { x: 0, y: 0 }#ele.position(dim)
// Get one coordinate
ele.position(dim: string): number | undefinedRead one coordinate of the first element.
| Name | Description |
|---|---|
dim: string | the coordinate, 'x' or 'y' |
number | undefinedthe first element's coordinate, or undefined when empty
#eles.position(position)
// Set the position
eles.position(position: Position): thisSet the position on every unlocked node.
| Name | Description |
|---|---|
position: Position | the coordinates to write |
Fields of position
| Name | Description |
|---|---|
x: number | |
y: number |
thisthis collection, for chaining
Example
const result = eles.position({ x: 20, y: 10 });console.log(result === eles); // true#eles.position(dim, value)
// Set one coordinate
eles.position(dim: string, value: number): thisSet one coordinate on every unlocked node.
| Name | Description |
|---|---|
dim: string | the coordinate, 'x' or 'y' |
value: number | the coordinate to write |
thisthis collection, for chaining
Example
const result = eles.position('x', 20);console.log(result === eles); // trueAlso spelled eles.modelPosition, eles.point.