From 359d8867671ec413ed543116a0b9faf11a6b3dc8 Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Tue, 18 Jul 2023 11:57:58 +0200 Subject: [PATCH] Documentation --- amd/src/simpleline.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/amd/src/simpleline.js b/amd/src/simpleline.js index 7b6da28..d327403 100644 --- a/amd/src/simpleline.js +++ b/amd/src/simpleline.js @@ -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();