Class

Component

Component(x, y, width, height, scale) → {Component}

The base class for every "complex" component, doing some of the trivial work.

Constructor

# new Component(x, y, width, height, scale) → {Component}

Initiates a new component

Parameters:
Name Type Default Description
x number

X position in the parent SVG

y number

Y position in the parent SVG

width number

Height, for calculations

height number

Width, for calculations

scale number 1

The scale of the values

View Source index.js, line 6

The component object

Component

Methods

# createSVGElement(c) → {HTMLElement}

Puts together the HTML element with all it's sub element, ready to be added to a parent.

Parameters:
Name Type Default Description
c HTMLElement null

(Optional) Equivalent to setting the .renderContainer property.

View Source index.js, line 162

Returns the HTML element, containing all the children.

HTMLElement

# hide() → {void}

Makes the component invisible. Interactions shouldn't be possible anymore.

View Source index.js, line 51

void

# move(deltaX, deltaY) → {Position}

Move the component relative to its current position.

Parameters:
Name Type Description
deltaX number

The amount of

deltaY number

description

View Source index.js, line 192

The new position

Position

# moveToTop() → {boolean}

Moves the svg container to the top of the parent. The parent has to be specified earlier by setting .renderContainer to an HTML element

View Source index.js, line 127

Wether moving could be done or not. Returns false, if renderContainer isn't set.

boolean

# setComponentScale(newScale) → {number}

Scales the component and its children.

Parameters:
Name Type Description
newScale number

The new scale of the component

Deprecated:
  • Broken in many ways, use .setViewboxScale() instead.

View Source index.js, line 207

The new scale.

number

# setPosition(pos) → {object}

Change the coordinates in the parent svg element

Parameters:
Name Type Description
pos object

The new position object

x number

X coordinate

y number

Y coordinate

View Source index.js, line 149

The new position

object

# setViewboxScale(newScale) → {void}

Change the scale of the element using the viewBox property.

Parameters:
Name Type Description
newScale number

The new scale of the element

View Source index.js, line 232

void

# show() → {void}

Reverts hide

View Source index.js, line 59

void

# updateAttributes() → {void}

Updates the attributes of the SVG element in the DOM

View Source index.js, line 68

Void

void