#ele.relativePosition()
// Get the position
ele.relativePosition(): Position | undefinedRead the first element's position relative to its immediate compound parent. For orphans this equals the model position.
Position | undefinedthe first element's position, or undefined when empty
Example
console.log(cy.getElementById('a').relativePosition()); // { x: 0, y: 0 }#ele.relativePosition(dim)
// Get one coordinate
ele.relativePosition(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
Example
console.log(cy.getElementById('a').relativePosition('x')); // 0#eles.relativePosition(position)
// Set the position
eles.relativePosition(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.relativePosition({ x: 20, y: 10 });console.log(result === eles); // true#eles.relativePosition(dim, value)
// Set one coordinate
eles.relativePosition(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.relativePosition('x', 20);console.log(result === eles); // trueAlso spelled eles.relativePoint.