Class: Stage

Stage


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
Name Type Argument Description
parentEl HTMLElement <optional>

The element with which to attach the canvas.
If none given the body is used.

bgColor String <optional>

The parent element's bg color

document Object <optional>

For testing

window Object <optional>

For testing

fill Boolean <optional>

Set to false to not maximally fill viewport.
Default is true.

Author:
  • Chris Peters
Source:

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

Source:
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

Source:
Returns:

The new top, left, width, & height

Type
Object

_handleResize()

Calls _resizeElement for stage elements

Source:

_resizeElement(el)

Decides how to handle resize based on options

Parameters:
Name Type Description
el HTMLEntity

The element to resize

Source:

getCanvas()

Returns the canvas element

Source:
Returns:
Type
HTMLElement

getVideo()

Returns the video element

Source:
Returns:
Type
HTMLElement