Skip to content

GridConstraint

Overview

Main grid-layout logic. Usually used indirectly through GridBox, but can also be used directly (say, if nodes don't have the same parent, or a GridBox can't be used).

Throughout the documentation for grid-related items, the term "line" refers to either a row or column (depending on the orientation).

@author Jonathan Olson <jonathan.olson@colorado.edu>

Class GridConstraint

import { GridConstraint } from 'scenerystack/scenery';

Constructor

new GridConstraint( ancestorNode : Node, providedOptions? : GridConstraintOptions )

Instance Methods

layout()

(protected)

addCell( cell : GridCell )

removeCell( cell : GridCell )

dispose()

Releases references

getIndices( orientation : Orientation ) : number[]

getCell( row : number, column : number ) : GridCell | null

getCellFromNode( node : Node ) : GridCell | null

getCells( orientation : Orientation, index : number ) : GridCell[]

Static Methods

create( ancestorNode : Node, options? : GridConstraintOptions ) : GridConstraint

Type GridConstraintOptions

import type { GridConstraintOptions } from 'scenerystack/scenery';
  • spacing?: number | number[]
    Spacings are controlled in each dimension (setting spacing) will adjust both. If it's a number, it will be an extra gap in-between every row or column. If it's an array, it will specify the gap between successive rows/columns e.g. [ 5, 4 ] will have a spacing of 5 between the first and second lines, and 4 between the second and third lines. In that case, if there were a third line, it would have zero spacing between the second (any non-specified spacings for extra rows/columns will be zero). NOTE: If a line (row/column) is invisible (and excludeInvisible is set to true), then the spacing that is directly after (to the right/bottom of) that line will be ignored.
  • xSpacing?: number | number[]
  • ySpacing?: number | number[]
  • preferredWidthProperty?: TProperty<number | null>
    The preferred width/height (ideally from a container's localPreferredWidth/localPreferredHeight.
  • preferredHeightProperty?: TProperty<number | null>
  • minimumWidthProperty?: TProperty<number | null>
    The minimum width/height (ideally from a container's localMinimumWidth/localMinimumHeight.
  • minimumHeightProperty?: TProperty<number | null>
  • & ExternalGridConfigurableOptions & NodeLayoutAvailableConstraintOptions

Source Code

See the source for GridConstraint.ts in the scenery repository.