Skip to main content

MagnetizeOptions

Options for the magnetize functionality of the UI.

Properties

afterDrag?

optional afterDrag: boolean

If true, magnetizer will be run after a vertex is dragged. Defaults to false.


afterGroupCollapse?

optional afterGroupCollapse: boolean

Defaults to false. Indicates the UI should gather nodes around a newly collapsed group


afterGroupExpand?

optional afterGroupExpand: boolean

Defaults to false. Indicates the UI should magnetize nodes around a newly expanded group


afterGroupGrow?

optional afterGroupGrow: boolean

Defaults to false. Indicates the UI should magnetize/gather nodes around a newly resized group if the group size was enlarged.


afterGroupResize?

optional afterGroupResize: boolean

Defaults to false. Indicates the surface should magnetize/gather nodes around a newly resized group, regardless of whether the group size grew or if it shrunk. This flag is the same as setting afterGroupShrink and afterGroupGrow


afterGroupShrink?

optional afterGroupShrink: boolean

Defaults to false. Indicates the UI should magnetize/gather nodes around a newly resized group if the group size was reduced.


afterLayout?

optional afterLayout: boolean

If true, magnetizer will be run after the layout is run.


constant?

optional constant: boolean

If true, magnetizer will be run constantly as a vertex is being dragged, pushing other vertices out of the way of the vertex that is being dragged. Defaults to false. By default, constant magnetize will also set trackback:true, but you can disable that behaviour by setting trackback:false.


constrainToViewport?

optional constrainToViewport: boolean

If true, vertices moved by the magnetizer will be constrained to move within the visible viewport, which is a function of the current zoom/pan of the UI. Otherwise, vertices will be able to be pushed out of the visible viewport.


padding?

optional padding: PointXY

How much padding to leave between elements. Defaults to 100 pixels in each axis.


repositionDraggedElement?

optional repositionDraggedElement: boolean

If true, and afterDrag is true, when the magnetizer is run after a drag it will be the recently dragged element that moves in precedence to the other elements. By default, the recently dragged element is not moved by the magnetize operation - it stays where you dragged it.


trackback?

optional trackback: boolean

Used in conjunction with constant: attempts to track any moved elements to their original positions (or as close as possible) once the path is clear, each time the magnetizer runs a sweep. Defaults to true (when constant is true).


trackbackThreshold?

optional trackbackThreshold: number

When in constant mode and trackback is set, this value specifies a threshold for elements that have been pushed from their original position. Beyond this threshold, the magnetizer will no longer attempt to track an element back. This can be useful in certain situations where the user does want to move an element by pushing it via the magnetizer