Class: Element

algo.render. Element

<abstract> new Element(_options)

the base class of renderable elements e.g. algo.render.Rectangle etc.
Parameters:
Name Type Description
_options
Source:

Members

<static> fadeIn :boolean

if true then new elements get the fade in keyframe animation. During history update the fade in effect is unattractive since you are skipping between frames quickly
Type:
  • boolean
Source:

<static> nextID

each element is assigned a unique ID upon construction. This ID is used as an attribute within the element to make finding the element in the DOM easier.
Source:

Methods

<static> enterHistoryMode()

start history mode which basically means remember currently allocated elements and reset
Source:

<static> exitHistoryMode()

exit history mode
Source:

<static> findElement(id)

find an element by its id
Parameters:
Name Type Description
id
Source:

<static> prefixed(propertyName)

return the given CSS property name appropriately prefixed for the browser we are on. Since method will only work correctly when inside the DOM, and therefore is only available to the element through methods like updateDOM. NOTE. It is also dumb, its simple prefixes the given string with the browser prefix.
Parameters:
Name Type Description
propertyName string
Source:

<static> resetClass()

when you want to reset the element class i.e. when restarting the animation.
Source:

<static> set(options, var_args, depth)

this is static version of the algo.render.Element.prototype.set Since it does not operate on a specific instance it accepts a variable number of arguments with an optional final depth parameter which defaults to zero. The optional arguments must be individual element instances or arrays or elements or objects with properties that are elements. You can supply objects or arrays which do not exclusively hold element, objects of other types will be ignored. The .set method of each element will be called e.g. algo.render.Element.set({x:0}, element1, "abc", element2, [element3, element4, { element: element5}, 3.1415; would invoke set on element1, element2, element3, element4, element5
Parameters:
Name Type Argument Description
options
var_args elements <repeatable>
zero or more element instances or arrays of element instances
depth <optional>
if the last argument is a number it is passed as the depth parameter to the instances set method
Source:

addChild(e)

add a child element
Parameters:
Name Type Description
e
Source:

addStates(states)

add new states in the given object
Parameters:
Name Type Description
states
Source:

createDOM()

create the DOM element for this instance. The base class is simply an absolutely positioned div
Source:

destroy()

destroyy the element, remove from parent. Destroy all children first, then ourselves.
Source:

fillBox(layout)

position and size to fill the given box
Parameters:
Name Type Description
layout
Source:

<abstract> fromShape(shape)

get our geometry from some other shape. This is meaningfully implemented in progeny objects
Parameters:
Name Type Description
shape Object any object that shares the geometrical properties of the
Source:

get(properties) → {object}

shallow clone the properties from the object, using inheritance to fill values if not present on the object. Values that are not present will be left untouched and therefore can be pre-filled with defaults.
Parameters:
Name Type Description
properties
Source:
Returns:
a new properties objects with requested values.
Type
object

getBounds()

a box object representing our bounds
Source:

getCSSColor(obj) → {String}

return a CSS color specification from any object / string that can be used to construct an algo.Color
Parameters:
Name Type Description
obj String | algo.Color
Source:
Returns:
- for colors with alpha === 1.0 it will be '#xxxxxx', otherwise 'rgba(x,x,x,x)' NOTE: This should have been static but its too late now...just use algo.render.Element.prototype.getCSSColor.call(null, obj)
Type
String

getInheritedValue(key)

get the value for the given property from the object or the nearest parent where it is set. if the property is not found in the chain then return the default value
Parameters:
Name Type Description
key
Source:

getOwnValue(key)

get the value for the given property from the object if set otherwise return the default value
Parameters:
Name Type Description
key
Source:

layout(layout)

position / size the element within the given algo.render.Box object. The meaning is deferred to inheriting classes
Parameters:
Name Type Description
layout
Source:

removeChild(e)

remove the child from this elements child collection
Parameters:
Name Type Description
e
Source:

set(options)

apply all the properties in options. child class should overload by but call the base class to ensure base class properties are set as well.
Parameters:
Name Type Description
options
Source:

setState(stateName)

apply the properties of the state specified by name e.g. algo.render.kS_BLUE, but could be any name including custom states supplied by user
Parameters:
Name Type Description
stateName string
Source:

update()

ensure the DOM is created and updated and apply the same procedure to our children
Source:

updateDOM()

get an object with our CSS properties. These are combined with those of inheriting classes to construct the full set of CSS properties for this element
Source: