new Stage(width, height, opts)
Creates and handles the canvas element. included in the options
parameter is optional dependency injection used for testing against
a virtual dom.
Parameters:
Name | Type | Argument | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
width |
Integer |
<optional> |
The width of the canvas |
||||||||||||||||||||||||
height |
Integer |
<optional> |
The height of the canvas |
||||||||||||||||||||||||
opts |
Object |
<optional> |
Stage options Properties
|
Methods
-
<static> center(width, height, viewportWidth, viewportHeight)
-
Keeps stage element centered in the viewport
Parameters:
Name Type Description width
Integer The element's original width attribute
height
Integer The element's original height attribute
viewportWidth
Integer The viewport's current width
viewportHeight
Integer The viewport's current height
Returns:
The top and left
- Type
- Object
-
<static> fill(width, height, viewportWidth, viewportHeight)
-
Maximizes an element (with aspect ratio intact) in the viewport via CSS.
Parameters:
Name Type Description width
Integer The element's original width attribute
height
Integer The element's original height attribute
viewportWidth
Integer The viewport's current width
viewportHeight
Integer The viewport's current height
Returns:
The new top, left, width, & height
- Type
- Object
-
_handleResize()
-
Calls _resizeElement for stage elements
-
_resizeElement(el)
-
Decides how to handle resize based on options
Parameters:
Name Type Description el
HTMLEntity The element to resize
-
getCanvas()
-
Returns the canvas element
Returns:
- Type
- HTMLElement
-
getVideo()
-
Returns the video element
Returns:
- Type
- HTMLElement