Skip to main content

Magnetizer

Offers a means to apply 'magnetization' to some list of elements, pushing them apart so that they do not overlap. For a given run of the magnetizer there is the concept of a "focus" rectangle. The center of this rectangle is the point from which magnetization occurs, with elements being pushed out radially from this point. There are a few different scenarios:

  • execute magnetizer with a given origin, and affect all elements
  • execute magnetizer on all elements, having first computed the center of them
  • execute magnetizer using a specific element as the focus

Type Parameters

T

T extends HasId

Methods

executeAtCenter()

executeAtCenter(options?): MagnetizeResult

Run the magnetizer using an origin computed to be the center of all elements.

Parameters

options?

MagnetizerRunOptions<T>

Returns

MagnetizeResult


executeAtPoint()

executeAtPoint(origin, options?): MagnetizeResult

Run the magnetizer using the specified origin.

Parameters

origin

PointXY

options?

MagnetizerRunOptions<T>

Returns

MagnetizeResult


executeWithFocus()

executeWithFocus(focus, options?): MagnetizeResult

Run the magnetizer with the given element as its focus - the focus element will not be shifted.

Parameters

focus

string

options?

MagnetizerRunOptions<T>

Returns

MagnetizeResult


snapToGrid()

snapToGrid(grid): MagnetizeResult

Snaps all elements to a grid. Returns a map of element IDs, representing all the elements that were moved.

Parameters

grid

Grid

Returns

MagnetizeResult