element.position(x, y, [opt])
Set the element position to x
and y
coordinates. This is almost equivalent to
element.set('position', { x: x, y: y }, opt)
. However, this method provides some additional functionality.
If you set opt.parentRelative
flag to true
, the x
and y
coordinates will be treated relatively to the parent element of this element. If position()
is called
without arguments, it returns the current position. If position({ parentRealtive: true })
is called
without x
and y
coordinates and with the parentRelative
flag set to true
,
the method returns the current position of the element relative to its parent.
Setting opt.deep
to true
will position not only the element but also all its descendants keeping
the original distances from a child to the element origin.
el1.position(100, 100);
el1.embed(el2);
el2.position(10, 10, { parentRelative: true });
el2.position() // --> 110@110
el1.position(200,200, { deep: true });
el2.position() // --> 210@210