RenderTreeNode Class
samsara/core/nodes/RenderTreeNode.js:15
A node in the render tree. As such, it wraps a layout or size node,
providing them with an add
method. By adding nodes, the render tree
is constructed, the leaves of which are Surfaces
.
Constructor
RenderTreeNode
-
object
Parameters:
-
object
Object | SizeNode | LayoutNode | Surface | View
Methods
add
-
node
Extends the render tree with a new node. Similar to how a tree data structure is created, but instead of a node with an array of children, children subscribe to notifications from the parent.
Nodes can be instances of LayoutNode
, SizeNode
, or Object literals with
size and layout properties, in which case, appropriate nodes will be created.
This method also takes Views
(subtrees) and Surfaces
(leaves).
Parameters:
-
node
Object | SizeNode | LayoutNode | Surface | ViewNode
Returns:
compose
-
spec
-
parentSpec
-
size
Defines the rules for composing layout specs: transform, align, origin and opacity. Transform is multiplied by the parent's transform (matrix multiplication). Align is a proportional offset relative to the parent size. Origin is a proportional offset relative to the current size. Opacity is multiplied by the parent's opacity.
Parameters:
Returns:
The composed layout spec
compose
-
spec
-
parentSize
Defines the rules for composing size specs (size, margin, proportions) into a new size.
A margin array reduces the parent size by an amount specified in pixels.
A proportions array scales the parent size by a provided ratio.
A size array [width, height] can take true
, undefined
, or numeric values.
undefined
takes the parent value
true
takes the value defined by the DOM
numeric values override parent values
Returns:
size Composed size