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;
|
||||
}
|
||||
|
||||
.PEdge .lineText {
|
||||
text-anchor: middle;
|
||||
fill: black;
|
||||
}
|
||||
|
||||
#arrowhead {
|
||||
z-index: -1;
|
||||
fill: gray;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue