Crafty.domHelper

Collection of utilities for using the DOM.

Properties

Methods

Back to top

Crafty.domHelper.innerPosition

public Object Crafty.domHelper.innerPosition(HTMLElement obj)
obj

HTML element to calculate the position

[Returns]

Object with x key being the x position, y being the y position

Find a DOM elements position including padding and border.

Back to top

Crafty.domHelper.getStyle()

public Object Crafty.domHelper.getStyle(HTMLElement obj, String property)
obj

HTML element to find the style

property

Style to return

Determine the value of a style on an HTML element. Notation can be in either CSS or JS.

Back to top

Crafty.domHelper.translate()

public Object Crafty.domHelper.translate(Number clientX, Number clientY[, DrawLayer layer])
clientX

clientX position in the browser screen

clientY

clientY position in the browser screen

layer

a Crafty draw layer

[Returns]

Object {x: ..., y: ...} with Crafty coordinates.

The parameters clientX and clientY are pixel coordinates within the visible browser window. This function translates those to Crafty coordinates (i.e., the coordinates that you might apply to an entity), by taking into account where the stage is within the screen, what the current viewport is, etc.

If a draw layer is specified, the returned object will take into account any special scaling rules for that object.