Show:

A layout that arranges items in a grid and can rearrange the grid responsively.

The user provides the number of items per row in an array or a dictionary with keys that are pixel values. The items will be sized to fill the available space.

Let itemsPerRow be a dictionary if you want the grid to rearrange responsively. The keys should be pixel values. The row arrangement will be one of the entries of the dictionary whose key value is closest to the parent width without exceeding it.

Constructor

Layouts.GridLayout

(
  • [options]
)

Parameters:

  • [options] Object optional

    Options

    • itemsByRow Array | Object

      Number of items per row, or an object of {width : itemsByRow} pairs

    • [gutter=0] Transitionable | Number optional

      Gap space between successive items

Methods

"on"

(
  • type
  • handler
)

Inherited from Core.OptionsManager:

Adds a handler to the type channel which will be executed on emit.

Parameters:

add

(
  • object
)
RenderTreeNode

Inherited from Core.View:

Extends the render tree subtree with a new node.

Parameters:

  • object SizeNode | LayoutNode | Surface

    Node

Returns:

addItems

(
  • [items]
)

Add items to the layout.

Parameters:

  • [items] Array optional

    Array of Surfaces or Views

extend

(
  • protoObj
  • constants
)

Inherited from Core.Controller:

Allows a class to extend Controller. Note: this is a method defined on the Controller constructor

Parameters:

  • protoObj Object

    Prototype properties of the extended class

  • constants Object

    Constants to be added to the extended class's constructor

get

(
  • key
)
Object

Inherited from Core.OptionsManager:

Look up options value by key or get the full options hash.

Parameters:

Returns:

Object:

Associated object or full options hash

getOptions

(
  • key
)
Object

Inherited from Core.OptionsManager but overwritten in

Options getter.

Parameters:

Returns:

Object:

object Options value for the key

getSize

() Number[]

Inherited from Core.View:

Getter for size.

Returns:

Number[]:

size

key

(
  • key
)
OptionsManager

Inherited from Core.OptionsManager:

Return OptionsManager based on sub-object retrieved by key.

Parameters:

Returns:

OptionsManager:

Value

off

(
  • type
  • handler
)

Inherited from Core.OptionsManager:

Removes the handler from the type channel. This undoes the work of on.

Parameters:

OptionsManager.patch

(
  • options
  • patch
)
Object

Inherited from Core.OptionsManager but overwritten in

Constructor method. Create OptionsManager from source dictionary with arguments overriden by patch dictionary.

Parameters:

  • options Object

    Options to be patched

  • patch ...Object

    Options to overwrite

Returns:

Object:

source

patch

(
  • options
)
OptionsManager

Inherited from Core.OptionsManager:

Patch options with provided patches. Triggers change event on the object.

Parameters:

  • options Object

    Patch options

Returns:

OptionsManager:

this

set

(
  • sources
)

Inherited from Core.OptionsManager but overwritten in

Introduce new data streams to the layout node in {key : value} pairs. Here the key is one of "transform", "origin", "align" or "opacity". The value is either a stream, or a simple type like a Number or Array. Simple types will be wrapped in an Observerable to emit appropriate events.

Parameters:

  • sources Object

    Object of data sources

setOpacity

(
  • opacity
)

Inherited from Core.View:

Setter for opacity.

Parameters:

  • opacity Number | Stream

    Opacity

setOptions

(
  • options
)

Inherited from Core.OptionsManager but overwritten in

Options setter.

Parameters:

setOrigin

(
  • origin
)

Inherited from Core.View:

Setter for origin.

Parameters:

  • origin Number[] | Stream

    Origin as [x,y], or a stream.

setProportions

(
  • proportions
)

Inherited from Core.View but overwritten in

Setter for proportions.

Parameters:

  • proportions Number[] | Stream

    Proportions as [x,y], or a stream.

setSize

(
  • size
)

Inherited from Core.View:

Setter for size.

Parameters:

  • size Number[] | Stream

    Size as [width, height] in pixels, or a stream.

Attributes

DEFAULT_OPTIONS

readonly

Overwrite the DEFAULT_OPTIONS dictionary on the constructor of the class you wish to extend with the Controller to patch any options that are not prescribed on instantiation.

EVENTS

readonly

Overwrite the EVENTS dictionary on the constructor of the class you wish to extend with the Controller to include events in {key : value} pairs where the keys are event channel names and the values are functions to be executed.