Constructor
new module:Container(positionDefinitionopt, optionsopt)
Container constructor
Name | Type | Attributes | Description |
---|---|---|---|
positionDefinition | PositionDefinition | <optional> | Position in its container |
options | ContainerOptions | <optional> | Specific options |
Extends
Members
(static) defaultOptions :ContainerOptions
- ContainerOptions
(static) events :ContainerEvent
- ContainerEvent
children :Array.<Container>
- Array.<Container>
frameCount :Number
- Number
options :ContainerOptions
- ContainerOptions
parent :Container
- Container
position :Position
- Position
Methods
(static) from(definition) → {Container}
Return an instance from a generic object
Name | Type | Description |
---|---|---|
definition | Object | Container definition |
- Type:
- Container
(static) setOpacity(ctx, opacity)
Define context opacity
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | Drawing context |
opacity | Number | Opacity value |
add(…child) → {Container}
Add another container as a child
Name | Type | Attributes | Description |
---|---|---|---|
child | Container | <repeatable> | Another container |
Itself
- Type:
- Container
climbAncestry(callback, untilopt)
Execute an action on every ancestor of this
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback | ancestryCallback | Function to execute on each ancestor | ||
until | Container | <optional> | null | Define a ancestor where to stop the climbing |
clone() → {Container}
Create a copy of any descendant of Container
- Type:
- Container
delete() → {Container}
Remove itself from its parent
Itself
- Type:
- Container
empty() → {Container}
Remove all its children
Itself
- Type:
- Container
fire(event) → {Container}
Bubble the event to its parent
Name | Type | Description |
---|---|---|
event | BaseEvent | Event to fire |
- Overrides
Itself
- Type:
- Container
getAbsolutePosition() → {Position}
Get this container's absolute position (up to it's utmost parent)
- Type:
- Position
getRoot() → {Container}
Return its highest parent
Itself
- Type:
- Container
getScene() → {Promise.<Scene>}
Return a promise for the associated scene
- Type:
- Promise.<Scene>
getTarget(position, ctx) → {Container}
Find the target at a position
Name | Type | Description |
---|---|---|
position | Position | Any position |
ctx | CanvasRenderingContext2D | Drawing context to apply paths |
Itself
- Type:
- Container
hide() → {Container}
Hide it
Itself
- Type:
- Container
isAncestorOf(container) → {Boolean}
Define if this is an ancestor of another container
Name | Type | Description |
---|---|---|
container | Container | Any container |
- Type:
- Boolean
isHover() → {Boolean}
Container can't be hovered
- Type:
- Boolean
makePath() → {Container}
Do nothing on Container, override it to add behavior
Itself
- Type:
- Container
remove(…child) → {Container}
Remove a child from the list
Name | Type | Attributes | Description |
---|---|---|---|
child | Container | <repeatable> | Child to remove |
Itself
- Type:
- Container
render(ctx) → {Container}
Call the render method of all children
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | Drawing context |
Itself
- Type:
- Container
setContext(ctx) → {Container}
Set variables of the context according to specified options
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | Drawing context |
Itself
- Type:
- Container
setOptions(optionsopt) → {Container}
Define options for this container
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options | ContainerOptions | <optional> | {} | Options to override |
Itself
- Type:
- Container
show() → {Container}
Display it
Itself
- Type:
- Container
toJSON() → {Object}
Return a json ready object
- Type:
- Object
Type Definitions
ancestryCallback(ancestor)
Name | Type | Description |
---|---|---|
ancestor | Container |
ContainerEvent
- Object
Name | Type | Description |
---|---|---|
attach | String | Container is append to a new parent |
detach | String | Container remove from it's parent |
draw | String | Container is drawn |
hide | String | |
show | String |
ContainerOptions
- Object
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
shown | Boolean | <optional> | true | Is shown |
opacity | Number | <optional> | null | Opacity level from 0 to 1 (null mean inherited from parent) |
rotation | Number | <optional> | 0 | Rotation ratio from 0 to 1 (clockwise) |
rotationCenter | PositionDefinition | <optional> | new Position() | Center of rotation relative to this position |
scale | Number | | <optional> | 1 | Scaling ratio or a pair of value for horizontal and vertical scaling |
zIndex | Number | <optional> | 1 | Depth ordering |
clip | Component | <optional> | null | Other component used to clip the rendering |