Layouts.DrawerLayout Class
samsara/layouts/DrawerLayout.js:29
A layout composed of two sections: content and drawer.
The drawer is initially hidden behind the content, until it is moved by a call to setPosition. The source of the movement can be by subscribing the layout to user input (like a Mouse/Touch/Scroll input), or by manually calling setPosition with a transition.
The layout emits a start
, update
and end
Stream with payload
progress
- Number between 0 and 1 indicating how open the drawer is
value
- Pixel displacement in how open the drawer is
It also emits close
and open
events.
The drawer can be revealed from any side of the content (top, left, bottom, right), by specifying a side option.
Constructor
Layouts.DrawerLayout
-
[options]
Parameters:
-
[options]
Object optionalOptions
-
[side]
Number optionalSide to reveal the drawer from. Defined in DrawerLayout.SIDES
-
[revealLength]
Number optionalThe maximum length to reveal the drawer
-
[velocityThreshold]
Number optionalThe velocity needed to complete the drawer transition
-
[positionThreshold]
Number optionalThe displacement needed to complete the drawer transition
-
[transitionClose]
Object optionalA transition definition for closing the drawer
-
[transitionOpen]
Object optionalA transition definition for opening the drawer
-
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:
-
object
SizeNode | LayoutNode | SurfaceNode
Returns:
addContent
-
content
Set the content component with a Surface or View.
Parameters:
-
content
Surface | View
addDrawer
-
drawer
Set the drawer component with a Surface of View.
Parameters:
-
drawer
Surface | View
close
-
[transition]
-
[callback]
Conceals the drawer with a transition.
Emits a close
event when an closing transition has been committed to.
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
get
-
key
Look up options value by key or get the full options hash.
Parameters:
-
key
StringKey
Returns:
Associated object or full options hash
getOptions
-
key
Options getter.
Parameters:
-
key
StringKey
Returns:
object Options value for the key
key
-
key
Return OptionsManager based on sub-object retrieved by key
.
Parameters:
-
key
StringKey
Returns:
Value
off
-
type
-
handler
Removes the handler
from the type
channel.
This undoes the work of on
.
open
-
[transition]
-
[callback]
Reveals the drawer with a transition.
Emits an open
event when an opening transition has been committed to.
OptionsManager.patch
-
options
-
patch
Constructor method. Create OptionsManager from source dictionary with arguments overridden by patch dictionary.
Parameters:
-
options
ObjectOptions to be patched
-
patch
...ObjectOptions to override
Returns:
source
OptionsManager.setOptions
-
instance
-
options
-
defaults
Constructor method. Convenience method to set options with defaults on an object instance.
Parameters:
Returns:
Patched options
patch
-
options
Patch options with provided patches. Triggers change
event on the object.
Parameters:
-
options
ObjectPatch options
Returns:
this
remove
()
Remove the View from the RenderTree. All Surfaces added to the View will also be removed. The View can be added back at a later time and all of its data and Surfaces will be restored.
reset
-
[transition]
Resets to last state of being open or closed
set
-
key
-
value
Set key to value. Outputs change
event if a value is overwritten.
Returns:
Updated OptionsManager
setAspectRatio
-
aspectRatio
Setter for aspect ratio.
Parameters:
-
aspectRatio
Number | StreamAspect ratio, or a stream.
setMargins
-
margins
Setter for margins.
Parameters:
-
margins
Number[] | StreamMargins as [x,y], or a stream.
setOrigin
-
origin
Setter for origin.
Parameters:
-
origin
Number[] | StreamOrigin as [x,y], or a stream.
setPosition
-
position
-
[transition]
-
[callback]
Sets the position in pixels for the content's displacement.
setProportions
-
proportions
Setter for proportions.
Parameters:
-
proportions
Number[] | StreamProportions as [x,y], or a stream.
setSize
-
size
Setter for size.
Parameters:
-
size
Number[] | StreamSize as [width, height] in pixels, or a stream.