Documentation

This commit is contained in:
PMKuipers 2023-07-18 11:57:58 +02:00
parent 6675dcb272
commit 359d886767

View file

@ -204,6 +204,9 @@ export class SimpleLine {
this.update();
}
/**
* Check for an element positino change and update accordingly
*/
positionCheck(){
const startPos = {x: this.start.offsetLeft, y: this.start.offsetTop};
const endPos = {x: this.end.offsetLeft, y: this.end.offsetTop};
@ -275,6 +278,10 @@ export class SimpleLine {
return { x: x, y: y, dir: {x: dirX, y: dirY}};
}
/**
* Generates the svg defs parts including the marker
* @returns {Object}
*/
svgDefs(){
const defs = document.createElementNS("http://www.w3.org/2000/svg", "defs");
const marker = document.createElementNS("http://www.w3.org/2000/svg", "marker");
@ -292,7 +299,10 @@ export class SimpleLine {
return defs;
}
/**
* (Re)Paint the arrow
*
*/
update(){
if(!this.active){ return;} // don't do this if we are no longer active
@ -417,6 +427,9 @@ export class SimpleLine {
C ${startPos.dirx} ${startPos.diry}, ${endPos.dirx} ${endPos.diry}, ${endPos.x} ${endPos.y}`);
}
/**
* Remove the line element from the dom and invalidate it.
*/
remove(){
// remove the line
this.svg.remove();