diff --git a/html/index.html b/html/index.html index 32a7469..70ee892 100644 --- a/html/index.html +++ b/html/index.html @@ -67,6 +67,11 @@ stroke-width: 4; } + .PEdge .lineText { + text-anchor: middle; + fill: black; + } + #arrowhead { z-index: -1; fill: gray; diff --git a/js/PElems/Transition.ts b/js/PElems/Transition.ts index 468aca9..23dd1bb 100644 --- a/js/PElems/Transition.ts +++ b/js/PElems/Transition.ts @@ -38,11 +38,12 @@ export class Transition implements Positionable { return true; } fire() { + let canFire = this.#canFireC let canFireNow = this.canFire() - if(this.#canFireC && !canFireNow){ + if(canFire && !canFireNow){ // TODO: koflikt. } - if (!this.#canFireC || !canFireNow) return false; + if (!canFire || !canFireNow) return false; for (const inE of this.inEdges) { inE.suck(); } diff --git a/js/graphics/SVGArrow.ts b/js/graphics/SVGArrow.ts index 2bda327..e4352d6 100644 --- a/js/graphics/SVGArrow.ts +++ b/js/graphics/SVGArrow.ts @@ -16,12 +16,11 @@ export class SVGArrow implements HTMLappendIt { this.line.setAttribute('marker-end', "url(#arrowhead)"); this.group.setAttribute('transform', `translate(0, 0)`); - // Create the text inside the circle this.lineText = document.createElementNS(svgNamespace, 'text'); this.lineText.classList.add("lineText"); this.lineText.setAttribute('x', '0'); this.lineText.setAttribute('y', '0'); - this.lineText.textContent = ""; + this.lineText.textContent = "1"; this.group.appendChild(this.line); this.group.appendChild(this.lineText); @@ -38,6 +37,8 @@ export class SVGArrow implements HTMLappendIt { this.line.setAttribute('y1', (this.from.y + dy * 30) + ""); this.line.setAttribute('x2', (this.to.x - dx * 40) + ""); this.line.setAttribute('y2', (this.to.y - dy * 40) + ""); + this.lineText.setAttribute('x', this.from.x + dx / 2 + ""); + this.lineText.setAttribute('y', this.from.y + dy / 2 + ""); } appendIt(svg) { svg.appendChild(this.group); diff --git a/js/graphics/tragable.ts b/js/graphics/tragable.ts index 3180e3b..30b1108 100644 --- a/js/graphics/tragable.ts +++ b/js/graphics/tragable.ts @@ -12,11 +12,16 @@ export class Tragable { initTrag(element: SVGElement) { let svg = Tragable.getRootSVG(element); let selected = false; + let moved = true; element.addEventListener('mousedown', () => { selected = true; + moved = false; }); svg.addEventListener('mousemove', event => { - if (selected) this.#moveCB(event); + if (selected) { + moved = true; + this.#moveCB(event); + } }); svg.addEventListener('mouseup', () => { selected = false; @@ -25,7 +30,7 @@ export class Tragable { selected = false; }); element.addEventListener('click', event => { - if (!selected) this.#clickCB(event); + if (!selected && !moved) this.#clickCB(event); }); } diff --git a/js/index.ts b/js/index.ts index ea5fee8..4737b95 100644 --- a/js/index.ts +++ b/js/index.ts @@ -15,7 +15,7 @@ svg.appendChild(svgNodes); let transitions: Transition[] = []; let nodes: Node[] = []; -async function loop() { +function loop() { for (const trans of transitions) { trans.canFire(); }