module:Container

Container class

Constructor

new module:Container(positionDefinitionopt, optionsopt)

Container constructor

Parameters:
NameTypeAttributesDescription
positionDefinitionPositionDefinition<optional>

Position in its container

optionsContainerOptions<optional>

Specific options

Extends

Members

(static) defaultOptions :ContainerOptions

Type:
  • ContainerOptions

(static) events :ContainerEvent

Type:
  • ContainerEvent

children :Array.<Container>

Type:
  • Array.<Container>

frameCount :Number

Type:
  • Number

options :ContainerOptions

Type:
  • ContainerOptions

parent :Container

Type:
  • Container

position :Position

Type:
  • Position

Methods

(static) from(definition) → {Container}

Return an instance from a generic object

Parameters:
NameTypeDescription
definitionObject

Container definition

Returns:
Type: 
Container

(static) setOpacity(ctx, opacity)

Define context opacity

Parameters:
NameTypeDescription
ctxCanvasRenderingContext2D

Drawing context

opacityNumber

Opacity value

add(…child) → {Container}

Add another container as a child

Parameters:
NameTypeAttributesDescription
childContainer<repeatable>

Another container

Returns:

Itself

Type: 
Container

climbAncestry(callback, untilopt)

Execute an action on every ancestor of this

Parameters:
NameTypeAttributesDefaultDescription
callbackancestryCallback

Function to execute on each ancestor

untilContainer<optional>
null

Define a ancestor where to stop the climbing

clone() → {Container}

Create a copy of any descendant of Container

Returns:
Type: 
Container

delete() → {Container}

Remove itself from its parent

Returns:

Itself

Type: 
Container

empty() → {Container}

Remove all its children

Returns:

Itself

Type: 
Container

fire(event) → {Container}

Bubble the event to its parent

Parameters:
NameTypeDescription
eventBaseEvent

Event to fire

Returns:

Itself

Type: 
Container

getAbsolutePosition() → {Position}

Get this container's absolute position (up to it's utmost parent)

Returns:
Type: 
Position

getRoot() → {Container}

Return its highest parent

Returns:

Itself

Type: 
Container

getScene() → {Promise.<Scene>}

Return a promise for the associated scene

Returns:
Type: 
Promise.<Scene>

getTarget(position, ctx) → {Container}

Find the target at a position

Parameters:
NameTypeDescription
positionPosition

Any position

ctxCanvasRenderingContext2D

Drawing context to apply paths

Returns:

Itself

Type: 
Container

hide() → {Container}

Hide it

Returns:

Itself

Type: 
Container

isAncestorOf(container) → {Boolean}

Define if this is an ancestor of another container

Parameters:
NameTypeDescription
containerContainer

Any container

Returns:
Type: 
Boolean

isHover() → {Boolean}

Container can't be hovered

Returns:
Type: 
Boolean

makePath() → {Container}

Do nothing on Container, override it to add behavior

Returns:

Itself

Type: 
Container

remove(…child) → {Container}

Remove a child from the list

Parameters:
NameTypeAttributesDescription
childContainer<repeatable>

Child to remove

Returns:

Itself

Type: 
Container

render(ctx) → {Container}

Call the render method of all children

Parameters:
NameTypeDescription
ctxCanvasRenderingContext2D

Drawing context

Returns:

Itself

Type: 
Container

setContext(ctx) → {Container}

Set variables of the context according to specified options

Parameters:
NameTypeDescription
ctxCanvasRenderingContext2D

Drawing context

Returns:

Itself

Type: 
Container

setOptions(optionsopt) → {Container}

Define options for this container

Parameters:
NameTypeAttributesDefaultDescription
optionsContainerOptions<optional>
{}

Options to override

Returns:

Itself

Type: 
Container

show() → {Container}

Display it

Returns:

Itself

Type: 
Container

toJSON() → {Object}

Return a json ready object

Returns:
Type: 
Object

Type Definitions

ancestryCallback(ancestor)

Parameters:
NameTypeDescription
ancestorContainer

ContainerEvent

Type:
  • Object
Properties
NameTypeDescription
attachString

Container is append to a new parent

detachString

Container remove from it's parent

drawString

Container is drawn

hideString
showString

ContainerOptions

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
shownBoolean<optional>
true

Is shown

opacityNumber<optional>
null

Opacity level from 0 to 1 (null mean inherited from parent)

rotationNumber<optional>
0

Rotation ratio from 0 to 1 (clockwise)

rotationCenterPositionDefinition<optional>
new Position()

Center of rotation relative to this position

scaleNumber | PositionDefinition<optional>
1

Scaling ratio or a pair of value for horizontal and vertical scaling

zIndexNumber<optional>
1

Depth ordering

clipComponent<optional>
null

Other component used to clip the rendering