Get height of canvas
The bounding box of the canvas
Get a boolean to indicate whether the animation is playing
Get this space's bounding box
Get the mouse or touch pointer that stores the last action
Get the size of this bounding box as a Pt
Get width of canvas
Go through all the players
and call its action
callback function
an UIPointerActions constant or string: "up", "down", "move", "drag", "drop", "over", and "out"
mouse or touch event
MouseDown handler
MouseMove handler
MouseOut handler
MouseOver handler
MouseUp handler
TouchMove handler
Add an IPlayer to this space. An IPlayer can define the following callback functions:
animate( time, ftime, space )
start(bound, space)
resize( size, event )
action( type, x, y, event )
Subclasses of Space may define other callback functions.Bind event listener in canvas element. You can also use bindMouse
or bindTouch
to bind mouse or touch events conveniently.
an event string such as "mousedown"
callback function for this event
A convenient method to bind (or unbind) all mouse events in canvas element. All "players" added to this space that implements an action
callback property will receive mouse event callbacks. The types of mouse actions are defined by UIPointerActions constants: "up", "down", "move", "drag", "drop", "over", and "out". See Space
's add()
function for more details.
a boolean value to bind mouse events if set to true
. If false
, all mouse events will be unbound. Default is true.
A convenient method to bind (or unbind) all touch events in canvas element. All "players" added to this space that implements an action
callback property will receive mouse event callbacks. The types of mouse actions are: "up", "down", "move", "drag", "drop", "over", and "out".
a boolean value to bind touch events if set to true
. If false
, all mouse events will be unbound. Default is true.
clear all contents in the space
Get a default form for drawing in this space
Pause the animation
a boolean value to set if this function call should be a toggle (between pause and resume)
Main play loop. This implements window.requestAnimationFrame and calls it recursively.
Override this play()
function to implemenet your own animation loop.
current time
Main animate function. This calls all the items to perform
current time
Play animation loop, and then stop after duration
time has passed.
a value in millisecond to specify a time period to play before stopping, or -1
to play forever
Set whether the rendering should be repainted on each frame
a boolean value to set whether to repaint each frame
Remove a player from this Space
an IPlayer that has an animateID
property
Remove all players from this Space
Custom rendering
rendering context
Replay the animation after stop()
. This resets the end-time counter.
You may also use pause()
and resume()
for temporary pause.
Resize the space
Resume the pause animation
Specify when the animation should stop: immediately, after a time period, or never stops.
a value in millisecond to specify a time period to play before stopping, or -1
to play forever, or 0
to end immediately. Default is 0 which will stop the animation immediately.
A convenient method to convert the touch points in a touch event to an array of Pt
.
a touch event which contains touches, changedTouches, and targetTouches list
a string to select a touches list: "touches", "changedTouches", or "targetTouches". Default is "touches"
an array of Pt, whose origin position (0,0) is offset to the top-left of this space
Unbind a callback from the event listener
an event string such as "mousedown"
callback function to unbind
Generated using TypeDoc
Get the size of this bounding box as a Pt