Class: DOMHexagonalGrid

.dom~DOMHexagonalGrid(options)

A hexagonal grid with each node controlling the position of a dom element. Extends `BaseHexagonalGrid`.

Constructor

new DOMHexagonalGrid(options)

Construct a DOM-based hexagonal grid. See `BaseHexagonalGrid.constructor` for more valid options.
Parameters:
Name Type Description
options Object Optional values
Properties
Name Type Attributes Default Description
domParent DOMElement <optional>
document.body The dom element that the children should be added to.
autoResize boolean <optional>
true Where to automatically resize when the window size is adjusted.
elementType string <optional>
div The default tag type to create elements as
Source:

Members

default_options

Defines what the default values are for the options of this class when instantiated, see `DOMHexagonalGrid.Constructor` for more details.
Source:

nodeRadius

Dynamic getter that defines the radius of each node, based on the size of `DOMHexagonalGrid.domParent`
Source:

Methods

initialiseNode(node, data)

Overridable function that is called during `DOMHexagonalGrid.initialise()`, once for each node in `DOMHexagonalGrid.nodes`. By default it creates a new element of type `DOMHexagonalGrid.elementType`, and gives it the data attributes `data-hex_q=node.q` and `data-hex_r=node.r`, and appends it to `DOMHexagonalGrid.domParent`.
Parameters:
Name Type Description
node HexNode A hexagonal node
data Object The data stored relating to `node`.
Source:

postInitialise()

Overridable function that is called at the end of `DOMHexagonalGrid.initialise()`. By default it creates a style element in `document.head`, that defines some positions and widths for each node, using the class `node` and the data attributes `[data-hex_q]`, `[data-hex_r]` and `[data-hexgrid]`.
Source:

preInitialise()

Overridable function that is called at the start of `DOMHexagonalGrid.initialise()`. By default it gives the parent element a unique attribute `data-hexgrid=performance.now()`, and records the size of the element before new elements are added.
Source:

resize()

By default, removes the existing style element for this grid, and recalls `DOMHexagonalGrid.postInitialise()` to regenerate styles that match the current document size.
Source: