diff options
author | alyx <alyx@aleteoryx.me> | 2022-02-04 21:45:07 +0000 |
---|---|---|
committer | Aleteoryx <alyx@aleteoryx.me> | 2022-02-04 21:45:07 +0000 |
commit | 59d5ade418fdb0c6fe2d0c100f0a32b4c2dacd32 (patch) | |
tree | 9e5b9d73439d122f01672fe1f09fdaa9a8446f5f /grapher | |
parent | 1b43c68210da0e45dce23f37cc2cad9717ca4d75 (diff) | |
download | RRCUtils-59d5ade418fdb0c6fe2d0c100f0a32b4c2dacd32.tar.gz RRCUtils-59d5ade418fdb0c6fe2d0c100f0a32b4c2dacd32.tar.bz2 RRCUtils-59d5ade418fdb0c6fe2d0c100f0a32b4c2dacd32.zip |
fix a bug where wiring and stopping on the grid would unwire everything
Diffstat (limited to 'grapher')
-rw-r--r-- | grapher/script.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/grapher/script.js b/grapher/script.js index 9b0be9f..78b7efd 100644 --- a/grapher/script.js +++ b/grapher/script.js @@ -178,22 +178,22 @@ window.onload = async function() { rootel.addEventListener("mouseup", e => { if (e.button == 0) { + let newCon; switch (mode) { case 'wire_i-o': + connections.pop() + newCon = {i: wirestate.i, o: e.target} if (e.target.matches('.exec')) delConnections(e.target); - wirestate.o = e.target; - if (!e.target.parentElement.matches('.output')) - connections.pop(); - else if (wirestate.i.nextElementSibling.innerText != wirestate.o.nextElementSibling.innerText) - connections.pop(); + if (e.target.parentElement.matches('.output') && (newCon.i.nextElementSibling.innerText == newCon.o.nextElementSibling.innerText)) + connections.push(newCon); break; case 'wire_o-i': - if (!e.target.matches('.exec')) delConnections(e.target); - wirestate.i = e.target; - if (!e.target.parentElement.matches('.input')) - connections.pop(); - else if (wirestate.i.nextElementSibling.innerText != wirestate.o.nextElementSibling.innerText) - connections.pop(); + connections.pop() + newCon = {o: wirestate.o, i: e.target} + if (!e.target.matches('.exec') && !e.target.matches('#graph')) delConnections(e.target); + if (e.target.parentElement.matches('.input') && (newCon.i.nextElementSibling.innerText == newCon.o.nextElementSibling.innerText)) + connections.push(newCon); + break; break; case 'drag': if ((performance.now() - start) < 150 && !targ.children[0].matches('#selected')) { |