Constructor
new Layer(name, group, svgElemopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | Layer name |
|
group |
SVGGElement | null | An existing SVG group element or null. If group and no svgElem, use group for this layer. If group and svgElem, create a new group element and insert it in the DOM after group. If no group and svgElem, create a new group element and insert it in the DOM as the last layer. |
|
svgElem |
SVGGElement |
<optional> |
The SVG DOM element. If defined, use this to add a new layer to the document. |
- Source:
Example
const l1 = new Layer('name', group); // Use the existing group for this layer.
const l2 = new Layer('name', group, svgElem); // Create a new group and add it to the DOM after group.
const l3 = new Layer('name', null, svgElem); // Create a new group and add it to the DOM as the last layer.
Members
(static) CLASS_NAME
Properties:
Name | Type | Description |
---|---|---|
CLASS_NAME |
string | class attribute assigned to all layer groups. |
- Source:
(static) CLASS_REGEX
Properties:
Name | Type | Description |
---|---|---|
CLASS_REGEX |
RegExp | Used to test presence of class Layer.CLASS_NAME |
- Source:
Methods
(static) isLayer(elem) → {boolean}
Test whether an element is a layer or not.
Parameters:
Name | Type | Description |
---|---|---|
elem |
SVGGElement | The SVGGElement to test. |
- Source:
Returns:
True if the element is a layer
- Type
- boolean
activate() → {void}
Active this layer so it takes pointer events.
- Source:
Returns:
- Type
- void
appendChildren(children) → {void}
Append children to this layer.
Parameters:
Name | Type | Description |
---|---|---|
children |
SVGGElement | The children to append to this layer. |
- Source:
Returns:
- Type
- void
deactivate() → {void}
Deactive this layer so it does NOT take pointer events.
- Source:
Returns:
- Type
- void
getGroup() → {SVGGElement}
Get the group element for this layer.
- Source:
Returns:
The layer SVG group
- Type
- SVGGElement
getName() → {string}
Get the layer's name.
- Source:
Returns:
The layer name
- Type
- string
getOpacity() → {Float}
Get layer opacity.
- Source:
Returns:
Opacity value.
- Type
- Float
getTitleElement() → {SVGTitleElement|null}
- Source:
Returns:
- Type
- SVGTitleElement | null
isVisible() → {boolean}
Is this layer visible?
- Source:
Returns:
True if visible.
- Type
- boolean
removeGroup() → {SVGGElement}
Remove this layer's group from the DOM. No more functions on group can be called after this.
- Source:
Returns:
The layer SVG group that was just removed.
- Type
- SVGGElement
setName(name, hrService) → {string|null}
Set the name of this layer.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The new name. |
hrService |
module:history.HistoryRecordingService | History recording service |
- Source:
Returns:
The new name if changed; otherwise, null.
- Type
- string | null
setOpacity(opacity) → {void}
Sets the opacity of this layer. If opacity is not a value between 0.0 and 1.0, nothing happens.
Parameters:
Name | Type | Description |
---|---|---|
opacity |
Float | A float value in the range 0.0-1.0 |
- Source:
Returns:
- Type
- void
setVisible(visible) → {void}
Set this layer visible or hidden based on 'visible' parameter.
Parameters:
Name | Type | Description |
---|---|---|
visible |
boolean | If true, make visible; otherwise, hide it. |
- Source:
Returns:
- Type
- void