Crafty.domHelper
Collection of utilities for using the DOM.
Properties
Methods
Crafty.domHelper.innerPosition
public Object Crafty.domHelper.innerPosition(HTMLElement obj[, Object out])
- obj
HTML element to calculate the position
- out
optional object to save result in
- [Returns]
Object with
x
key being thex
position,y
being they
position
Find a DOM elements position including padding and border.
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.
Crafty.domHelper.translate()
public Object Crafty.domHelper.translate(Number clientX, Number clientY[, DrawLayer layer[, Object out]])
- clientX
clientX position in the browser screen
- clientY
clientY position in the browser screen
- layer
a Crafty draw layer
- out
an optional object to save result in
- [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.