bug fix
This commit is contained in:
parent
484e5022d1
commit
56bd2bec6d
5 changed files with 19 additions and 7 deletions
|
@ -67,6 +67,11 @@
|
||||||
stroke-width: 4;
|
stroke-width: 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.PEdge .lineText {
|
||||||
|
text-anchor: middle;
|
||||||
|
fill: black;
|
||||||
|
}
|
||||||
|
|
||||||
#arrowhead {
|
#arrowhead {
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
fill: gray;
|
fill: gray;
|
||||||
|
|
|
@ -38,11 +38,12 @@ export class Transition implements Positionable {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
fire() {
|
fire() {
|
||||||
|
let canFire = this.#canFireC
|
||||||
let canFireNow = this.canFire()
|
let canFireNow = this.canFire()
|
||||||
if(this.#canFireC && !canFireNow){
|
if(canFire && !canFireNow){
|
||||||
// TODO: koflikt.
|
// TODO: koflikt.
|
||||||
}
|
}
|
||||||
if (!this.#canFireC || !canFireNow) return false;
|
if (!canFire || !canFireNow) return false;
|
||||||
for (const inE of this.inEdges) {
|
for (const inE of this.inEdges) {
|
||||||
inE.suck();
|
inE.suck();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,11 @@ export class SVGArrow implements HTMLappendIt {
|
||||||
this.line.setAttribute('marker-end', "url(#arrowhead)");
|
this.line.setAttribute('marker-end', "url(#arrowhead)");
|
||||||
this.group.setAttribute('transform', `translate(0, 0)`);
|
this.group.setAttribute('transform', `translate(0, 0)`);
|
||||||
|
|
||||||
// Create the text inside the circle
|
|
||||||
this.lineText = document.createElementNS(svgNamespace, 'text');
|
this.lineText = document.createElementNS(svgNamespace, 'text');
|
||||||
this.lineText.classList.add("lineText");
|
this.lineText.classList.add("lineText");
|
||||||
this.lineText.setAttribute('x', '0');
|
this.lineText.setAttribute('x', '0');
|
||||||
this.lineText.setAttribute('y', '0');
|
this.lineText.setAttribute('y', '0');
|
||||||
this.lineText.textContent = "";
|
this.lineText.textContent = "1";
|
||||||
|
|
||||||
this.group.appendChild(this.line);
|
this.group.appendChild(this.line);
|
||||||
this.group.appendChild(this.lineText);
|
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('y1', (this.from.y + dy * 30) + "");
|
||||||
this.line.setAttribute('x2', (this.to.x - dx * 40) + "");
|
this.line.setAttribute('x2', (this.to.x - dx * 40) + "");
|
||||||
this.line.setAttribute('y2', (this.to.y - dy * 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) {
|
appendIt(svg) {
|
||||||
svg.appendChild(this.group);
|
svg.appendChild(this.group);
|
||||||
|
|
|
@ -12,11 +12,16 @@ export class Tragable {
|
||||||
initTrag(element: SVGElement) {
|
initTrag(element: SVGElement) {
|
||||||
let svg = Tragable.getRootSVG(element);
|
let svg = Tragable.getRootSVG(element);
|
||||||
let selected = false;
|
let selected = false;
|
||||||
|
let moved = true;
|
||||||
element.addEventListener('mousedown', () => {
|
element.addEventListener('mousedown', () => {
|
||||||
selected = true;
|
selected = true;
|
||||||
|
moved = false;
|
||||||
});
|
});
|
||||||
svg.addEventListener('mousemove', event => {
|
svg.addEventListener('mousemove', event => {
|
||||||
if (selected) this.#moveCB(event);
|
if (selected) {
|
||||||
|
moved = true;
|
||||||
|
this.#moveCB(event);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
svg.addEventListener('mouseup', () => {
|
svg.addEventListener('mouseup', () => {
|
||||||
selected = false;
|
selected = false;
|
||||||
|
@ -25,7 +30,7 @@ export class Tragable {
|
||||||
selected = false;
|
selected = false;
|
||||||
});
|
});
|
||||||
element.addEventListener('click', event => {
|
element.addEventListener('click', event => {
|
||||||
if (!selected) this.#clickCB(event);
|
if (!selected && !moved) this.#clickCB(event);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ svg.appendChild(svgNodes);
|
||||||
let transitions: Transition[] = [];
|
let transitions: Transition[] = [];
|
||||||
let nodes: Node[] = [];
|
let nodes: Node[] = [];
|
||||||
|
|
||||||
async function loop() {
|
function loop() {
|
||||||
for (const trans of transitions) {
|
for (const trans of transitions) {
|
||||||
trans.canFire();
|
trans.canFire();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue