# 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 |
The component object
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. |
Returns the HTML element, containing all the children.
HTMLElement
# move(deltaX, deltaY) → {Position}
Move the component relative to its current position.
Parameters:
Name | Type | Description |
---|---|---|
deltaX |
number
|
The amount of |
deltaY |
number
|
description |
The new 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
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.
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 |
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 |
void