Crafty.DOM

Collection of utilities for using the DOM.

Methods and Properties

Back to top

Crafty.DOM.getStyle

public Object Crafty.DOM.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.DOM.inner

public Object Crafty.DOM.inner(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.DOM.translate

public Object Crafty.DOM.translate(Number clientX, Number clientY)
clientX

clientX position in the browser screen

clientY

clientY position in the browser screen

[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.

Back to top

Crafty.DOM.window

Object with width and height values representing the width and height of the window.