Skip to main content

Home > @jsplumbtoolkit/browser-ui > Surface > setPosition

Surface.setPosition() method

Sets the position of the given vertex, snapping it to a grid and applying the magnetizer, if necessary. If the given vertex is the child of some group then the group's layout is updated with the new position (and no magnetizer is run); otherwise the main layout is updated with the new position.

Other elements may be moved as a result of this method due to the magnetizer potentially running (Although if it runs, it is not guaranteed to move other elements). For each moved element, a node moved event is fired. All of the move events are contained within a single transaction on the Toolkit so if you undo this operation, all of the affected elements will return to where they were prior to the move.


setPosition(vertex: string | Node | Group | Element, x: number, y: number): void;


vertexstring | Node | Group | ElementThe vertex to set the position for
xnumberX position to set
ynumberY position to set