Layouts.GridLayout Class
samsara/layouts/GridLayout.js:11
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
Item Index
Methods
Attributes
Methods
"on"
-
type -
handler
Adds a handler to the type channel which will be executed on emit.
add
-
object
Extends the render tree subtree with a new node.
Parameters:
-
objectSizeNode | LayoutNode | SurfaceNode
Returns:
addItems
-
[items]
Add items to the layout.
Parameters:
-
[items]Array optionalArray of Surfaces or Views
extend
-
protoObj -
constants
Allows a class to extend Controller. Note: this is a method defined on the Controller constructor
get
-
key
Look up options value by key or get the full options hash.
Parameters:
-
keyStringKey
Returns:
Associated object or full options hash
getOptions
-
key
Options getter.
Parameters:
-
keyStringKey
Returns:
object Options value for the key
key
-
key
Return OptionsManager based on sub-object retrieved by key.
Parameters:
-
keyStringKey
Returns:
Value
off
-
type -
handler
Removes the handler from the type channel.
This undoes the work of on.
OptionsManager.patch
-
options -
patch
Constructor method. Create OptionsManager from source dictionary with arguments overriden by patch dictionary.
Parameters:
-
optionsObjectOptions to be patched
-
patch...ObjectOptions to overwrite
Returns:
source
patch
-
options
Patch options with provided patches. Triggers change event on the object.
Parameters:
-
optionsObjectPatch options
Returns:
this
set
-
sources
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:
-
sourcesObjectObject of data sources
setOrigin
-
origin
Setter for origin.
Parameters:
-
originNumber[] | StreamOrigin as [x,y], or a stream.
setProportions
-
proportions
Setter for proportions.
Parameters:
-
proportionsNumber[] | StreamProportions as [x,y], or a stream.
setSize
-
size
Setter for size.
Parameters:
-
sizeNumber[] | StreamSize as [width, height] in pixels, or a stream.