CanvasObjectContainer

CanvasObjectContainer

A class representing HTML div elements, or other CanvasObjectContainers. Just like the CanvasObject class this class has an init method that acts like super.


Constructor

new CanvasObjectContainer(divID, width, height, rootCanvasObjectContaineropt, floorColorStringopt)

Parameters:
Name Type Attributes Description
divID String

the id attribute value of the HTML div element.

width Number

the width of the div.

height Number

the height of the div.

rootCanvasObjectContainer CanvasObjectContainer <optional>

optional CanvasObjectContainer that should contain this one.

floorColorString String <optional>

the color for the floor CanvasObject of this CanvasObjectContainer, if no floor color is passed a floor CanvasObject is not created.

Members

constructor

div

The html div that this Class is referencing.

floor

An optional floor CanvasObject that is the bottom child of this class. If no floorColorString is passed during construction a floor CanvasObject is not created.

Methods

addChild(child, x, y) → {HTMLDivElement|CanvasObject}

Adds a html div element or CanvasObject to this CanvasObjectContainer.

Parameters:
Name Type Description
child HTMLDivElement | CanvasObject
x Number
y Number
Returns:
Type
HTMLDivElement | CanvasObject

addChildAt(child, index, x, y) → {HTMLDivElement|CanvasObject}

Ads a HTML div element or CanvasObject to this CanvasObjectContainer at the index and x y location given.

Parameters:
Name Type Description
child HTMLDivElement | CanvasObject
index Number

the index the child should have in the CanvasObjectContainer lower indexes are beneath other children.

x Number
y Number
Returns:
Type
HTMLDivElement | CanvasObject

contains(child) → {Boolean}

Returns true if the CanvasObjectContainer contains the given child.

Parameters:
Name Type Description
child HTMLDivElement | CanvasObject
Returns:
Type
Boolean

getChildAt(index) → {HTMLDivElement|CanvasObject}

Gets the child that is at the given index.

Parameters:
Name Type Description
index Number
Returns:
Type
HTMLDivElement | CanvasObject

getChildIndex(child) → {Number}

Returns the index of the child in this CanvasObjectContainer. Call contains to check if the child is a child of this CanvasObjectContainer.

Parameters:
Name Type Description
child HTMLDivElement | CanvasObject
Returns:
Type
Number

getHeight() → {Number}

Returns the set height of this CanvasObjectContainer.

Returns:
Type
Number

getNumChildren() → {Number}

Returns the number of children that this CanvasObjectContainer has.

Returns:
Type
Number

getWidth() → {Number}

Returns the width of this CanvasObjectContainer

Returns:
Type
Number

init(divID, width, height, rootCanvasObjectContaineropt, floorColorStringopt)

Acts like a super method for inheriting Classes.

Parameters:
Name Type Attributes Description
divID String

the id attribute value of the HTML div element.

width Number

the width of the div.

height Number

the height of the div.

rootCanvasObjectContainer CanvasObjectContainer <optional>

optional CanvasObjectContainer that should contain this one.

floorColorString String <optional>

the color for the floor CanvasObject of this CanvasObjectContainer, if no floor color is passed a floor CanvasObject is not created.

removeChild(child) → {HTMLDivElement|CanvasObject}

Removes a child from this CanvasObjectContainer.

Parameters:
Name Type Description
child HTMLDivElement | CanvasObject
Returns:
Type
HTMLDivElement | CanvasObject

setChildIndex(child, index, x, y)

Sets the index of the child to the index given.

Parameters:
Name Type Description
child HTMLDivElement | CanvasObject
index Number
x Number
y Number