Skip to main content

VertexDrawingPluginOptions

Options for the vertex drawing plugin

Extends

Properties

allowClickToAdd?

optional allowClickToAdd: boolean

Defaults to false. When true, users can click on the canvas to "draw" a new element, and the plugin will use a default size for the element. When this flag is set, drag to add is still also enabled.


autoExit?

optional autoExit: boolean

When true (which is the default) the lasso exits after a group has been drawn


clickToAddOnly?

optional clickToAddOnly: boolean

Defaults to false. When true, the plugin only supports click to add new vertices, not drag. This flag is forced to true if the associated UI does not have useModelForSizes set, since there is no point in allowing a user to drag a vertex to some size if its not going to be honoured. When you set this flag and associated UI does have useModelForSizes set, the plugin will use default sizes for new nodes/groups.


defaultGroupSize?

optional defaultGroupSize: Size

Optional default size for groups, used when allowClickToAdd is set to true. Defaults to width and height of 250 pixels.


defaultNodeSize?

optional defaultNodeSize: Size

Optional default size for nodes, used when allowClickToAdd is set to true. Defaults to width and height of 80 pixels.


groupType?

optional groupType: string

The type identifier for new groups. If you have also provided a typeGenerator this will be ignored. If you have not provided a typeGenerator but you have provided a nodeType, this will be ignored.


invert?

optional invert: boolean

Defaults to false, meaning the lasso is drawn as a rectangle. If true, the lasso is drawn as a set of masks, with the lasso area drawn as a "hole" in the masks.


lassoClass?

optional lassoClass: string

Optional extra class(es) to set on the lasso used for drawing.


minSize?

optional minSize: Size

The minimum size for vertices. If your user draws a vertex smaller than this it will be discarded. Defaults to a width/height of 50 pixels.


nodeType?

optional nodeType: string

The type identifier for new nodes. If you have also provided a typeGenerator this will be ignored.


onVertexAdded()?

optional onVertexAdded: (v) => any

Callback to invoke when a vertex has been added

Parameters

v

Vertex

Returns

any


typeGenerator?

optional typeGenerator: VertexDrawingPluginTypeGenerator

Optional function that will be invoked when a new drag commences, and which is responsible for returning the type of object to add (Node or Group), as well as that object's own type, and, optionally, an initial payload for the new object.


vertexPreviewGenerator()?

optional vertexPreviewGenerator: (p, e) => BrowserElement

A function that will be invoked at the start of a drawing operation, and can return an element to draw into the lasso. This is an optional function; if you don't provide it VisuallyJs will draw a basic SVG rectangle to indicate the drawing area.

Parameters

p

PointXY

e

MouseEvent

Returns

BrowserElement


vertexPreviewUpdater()?

optional vertexPreviewUpdater: (p, size, el) => any

A function that is invoked during mouse drag, to be used in conjunction with vertexPreviewGenerator. This function gives you a hook to use to make any changes to your preview element, should you need to. This is optional.

Parameters

p

PointXY

size

Size

el

BrowserElement

Returns

any