Procházet zdrojové kódy

fix node add stuff

main
Martin Dørum před 4 roky
rodič
revize
4f5f5fd954
1 změnil soubory, kde provedl 3 přidání a 3 odebrání
  1. 3
    3
      src/CircuitSim.svelte

+ 3
- 3
src/CircuitSim.svelte Zobrazit soubor

if (this.cursorAttachedNode != null) { if (this.cursorAttachedNode != null) {
let node = this.cursorAttachedNode; let node = this.cursorAttachedNode;
let newX = Math.round(x - node.width / 2); let newX = Math.round(x - node.width / 2);
let newY = Math.round(y - node.height / 2);
let newY = Math.round(y - node.height / 2 + 0.5);
if (newX != node.x || newY != node.y) { if (newX != node.x || newY != node.y) {
node.x = newX; node.x = newX;
node.y = newY; node.y = newY;
if (this.cursorAttachedNode != null) { if (this.cursorAttachedNode != null) {
let node = this.cursorAttachedNode; let node = this.cursorAttachedNode;
node.x = Math.round(x - node.width / 2); node.x = Math.round(x - node.width / 2);
node.y = Math.round(y - node.height / 2);
node.y = Math.round(y - node.height / 2 + 0.5);
this.cursorAttachedNode = null; this.cursorAttachedNode = null;
return; return;
} }


addNodeAtCursor(node) { addNodeAtCursor(node) {
node.x = Math.round(this.cursorX - node.width / 2); node.x = Math.round(this.cursorX - node.width / 2);
node.y = Math.round(this.cursorY - node.height / 2);
node.y = Math.round(this.cursorY - node.height / 2 + 0.5);
this.nodes.push(node); this.nodes.push(node);
this.cursorAttachedNode = node; this.cursorAttachedNode = node;
this.requestFrame(); this.requestFrame();

Načítá se…
Zrušit
Uložit