DOM.Context Class
samsara/dom/Context.js:30
A Context defines a top-level DOM element inside which other nodes (like Surfaces) are rendered.
The CSS class samsara-context
is applied, which provides the minimal CSS necessary
to create a performant 3D context (specifically preserve-3d
).
The Context must be mounted to a DOM node via the mount
method. If no node is specified
it is mounted to document.body
.
Constructor
DOM.Context
-
[options]
Parameters:
Example:
var context = Context();
var surface = new Surface({
size : [100,100],
properties : {background : 'red'}
});
context.add(surface);
context.mount(document.body)
Item Index
Methods
Methods
add
-
Renderable
Extends the render tree beginning with the Context's RootNode with a new node.
Delegates to RootNode's add
method.
Parameters:
-
Renderable
Object
Returns:
Wrapped node
emit
-
type
-
data
Used internally when context is subscribed to.
getPerspective
()
Number
Get current perspective of this Context in pixels.
Returns:
Perspective in pixels
on
-
type
-
handler
Adds a handler to the type
channel which will be executed on emit
.
These events should be DOM events that occur on the DOM node the
context has been mounted to.
on
-
type
-
handler
Removes the handler
from the type
.
Undoes the work of on
.
setPerspective
-
perspective
-
[transition]
-
[callback]
Set current perspective of the context
in pixels.