Class: Element

Element

Element Class //* @extends Container

new Element(options)

constructs an Element instance
Parameters:
Name Type Description
options Object the options object to be merged with defaults

Methods


align(parentElement, mode)

Aligns the Element instance, based on it's parent bounds or specified parentElement bounds and mode parameter
Parameters:
Name Type Description
parentElement Object | null if null, it considers the actual Element instance parent, otherwise it aligns in base of the specified parentElement
mode String can be a set of one or two strings (blank separated) in any order, for horizontalModes (left, center, right), for verticalModes (top, middle, bottom)
Returns:
to make chainable the method
Type
Element

bindEvents()

binds all events specified in the settings object for the Element instance, it supports all DrawJS classes events (eg. click, mouseover, etc...)

draw()

draws all graphic elements of the Element instance

getComputedBounds()

returns the actual computed bounds of the Element instance, including scale factor and top, right, bottom, left coordinates
Returns:
the actual Element instance computed bounds object
  {
    {
      top: number,
      right: number,
      bottom: number,
      left: number,
      x: number,
      y: number,
      width: number,
      height: number
    }
  }
Type
Object

init()

empty init method, to be overriden in classes that extends Element, to use for all those initializations you might need after having rendered the Element

initData()

initializes data object for the Element instance

initDefaults(defaults)

initializes default settings for Element instance
Parameters:
Name Type Description
defaults Object the defaults object for Element instance

initSettings(options)

initializes settings object for the Element instance
Parameters:
Name Type Description
options Object the options object to be merged with defaults

setCache(cacheOptions, force)

sets or updates the Cache of the Element instance
Parameters:
Name Type Description
cacheOptions Object | Shadow ..
force Boolean ....
Returns:
to make chainable the method
Type
Element

setComputedBounds(boundsOptions)

sets or updates the bounds of the Element instance
Parameters:
Name Type Description
boundsOptions Object | Number ...
Returns:
to make chainable the method
Type
Element

setMask(maskOptions, force)

sets or updates the Mask of the Element instance
Parameters:
Name Type Description
maskOptions Object | Shadow can be an object with {color, x, y, blur}
or directly an instance of Shadow (DrawJS)
force Boolean ....
Returns:
to make chainable the method
Type
Element

setPosition( [positionOptions] [, override] [, force])

sets or updates the position of the Element instance
Parameters:
Name Type Argument Default Description
positionOptions Object <optional>
null can contain x and y or only one or them
Properties
Name Type Argument Default Description
x Number <optional>
0 the x position
y Number <optional>
0 the y position
override Boolean <optional>
false specify to override actual Element position
force Boolean <optional>
true ...
Returns:
to make chainable the method
Type
Element

setReg()

sets to center/middle the regPoint of the Element instance

setScale(scaleOptions)

sets or updates the scaling of the Element instance
Parameters:
Name Type Description
scaleOptions Object | Number can be an object with x and y couple or only a number to be used for both
Returns:
to make chainable the method
Type
Element

setScale(scaleOptions)

sets or updates the scaling of the Element instance
Parameters:
Name Type Description
scaleOptions Object | Number can be an object with x and y couple or only a number to be used for both
Returns:
to make chainable the method
Type
Element

setScale(scaleOptions)

sets or updates the scaling of the Element instance
Parameters:
Name Type Description
scaleOptions Object | Number can be an object with x and y couple or only a number to be used for both
Returns:
to make chainable the method
Type
Element

setShadow(shadowOptions, force)

sets or updates the Shadow of the Element instance
Parameters:
Name Type Description
shadowOptions Object | Shadow can be an object with {color, x, y, blur}
or directly an instance of Shadow (DrawJS)
force Boolean ....
Returns:
to make chainable the method
Type
Element