Class: GameArea

hcje/domTools.GameArea(config, maxScaleopt, fixedScaleopt, atTopopt)

GameArea object which encapsulates the dynamic game area. This area is a div which is centred on screen and then scaled to ensure it fits the screen or parent element.

Constructor

new GameArea(config, maxScaleopt, fixedScaleopt, atTopopt)

Create a game area. The game area is created with a class of 'hcje-game-area'. This is absolutely positioned and centered.

Parameters:
Name Type Attributes Default Description
config Object
Properties
Name Type Attributes Default Description
width number

Design width

height number

Design height

fitWithin Element <optional>

Element into which the game area should fit. If omitted a div that covers the full size of the window is created.

margin number <optional>
0

Margin required around the game area.

maxScale number <optional>

Maximum allowed scale. Defaults to unlimited.

fixedScale boolean <optional>
false

If true, prevents automatically rescaling if window resizes.

atTop boolean <optional>
false

The game area is normally centered but it can be set to the top but still centered horizonally.

Source:

Extends

Members

(protected, readonly) _element :Element

The wrapped element. This is protected and is only intended for use by the domTools module.

Type:
  • Element
Overrides:
Source:

(readonly) classList :DOMTokenList

The classList.

Type:
  • DOMTokenList
Overrides:
Source:
See:

className :string

The class name.

Type:
  • string
Overrides:
Source:
See:

(readonly) designBounds :module:hcje/utils~RectData

Get the design bounds.

Type:
Source:

(readonly) designDims :module:hcje/utils~Dimensions

Get the design dimensions.

Type:
Source:

(readonly) offsetHeight :number

Element's offset height.

Type:
  • number
Overrides:
Source:

(readonly) offsetWidth :number

Element's offset width.

Type:
  • number
Overrides:
Source:

(readonly) parentElement :string

The parent element.

Type:
  • string
Overrides:
Source:
See:

(readonly) scaledDims :module:hcje/utils~Dimensions

Get the scaled dimensions.

Type:
Source:

(readonly) style :CSSStyleProperties

Element's style.

Type:
  • CSSStyleProperties
Overrides:
Source:
See:

Methods

addEventListener(eventType, listener, optionsOrUseCapture)

Add event listener.

Parameters:
Name Type Description
eventType string

Event type to listen to

listener function | Object

Handler of the event

optionsOrUseCapture Object | boolean

Additional options

Overrides:
Source:
See:

appendChild(child)

Append child.

Parameters:
Name Type Description
child Element | ElementWrapper

Element to append

Overrides:
Source:
See:

appendTo(parentElement)

Append to a parent element. Note, if it is already a child, this call is ignored. This method is provided to allow callers to adust hierarchies without needing access to the protected wrapped element. Note that the method will silently return if parentElement is not provided.

Parameters:
Name Type Description
parentElement module:hcje/domTools~ElementWrapper | HTMLElement

The element to which the wrapped element should be appended.

Overrides:
Source:

blur()

Remove the element's focus.

Overrides:
Source:

focus()

Give the element focus.

Overrides:
Source:

remove()

Remove the element from the DOM. The instance wrapping the element still exists if a reference to it is maintained.

Overrides:
Source:

removeAllChildren()

Remove all children.

Overrides:
Source: