Skip to main content
MagnetizeOptions
Options for the magnetize functionality of the UI.
NameTypeDescription
afterDrag?booleanIf true, magnetizer will be run after a vertex is dragged. Defaults to false.
afterGroupCollapse?booleanDefaults to false. Indicates the UI should gather nodes around a newly collapsed group
afterGroupExpand?booleanDefaults to false. Indicates the UI should magnetize nodes around a newly expanded group
afterGroupGrow?booleanDefaults to false. Indicates the UI should magnetize/gather nodes around a newly resized group if the group size was enlarged.
afterGroupResize?booleanDefaults 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?booleanDefaults to false. Indicates the UI should magnetize/gather nodes around a newly resized group if the group size was reduced.
afterLayout?booleanIf true, magnetizer will be run after the layout is run.
constant?booleanIf 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?booleanIf 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?PointXYHow much padding to leave between elements. Defaults to 100 pixels in each axis.
repositionDraggedElement?booleanIf 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?booleanUsed 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?numberWhen 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