aboutsummaryrefslogtreecommitdiffstats
path: root/grapher
diff options
context:
space:
mode:
authoralyx <alyx@aleteoryx.me>2022-06-06 18:16:16 +0000
committerAleteoryx <alyx@aleteoryx.me>2022-06-06 18:16:16 +0000
commit7f6f5549fe6d1bd03772c13e96f9d92a26660929 (patch)
treef1102845189b3f57fed756d3b8b131bd3da87804 /grapher
parent5015300419d88ba5974124f0298d7488001ac4ba (diff)
downloadRRCUtils-7f6f5549fe6d1bd03772c13e96f9d92a26660929.tar.gz
RRCUtils-7f6f5549fe6d1bd03772c13e96f9d92a26660929.tar.bz2
RRCUtils-7f6f5549fe6d1bd03772c13e96f9d92a26660929.zip
goofy bits of gass and such, more typing
Diffstat (limited to 'grapher')
-rw-r--r--grapher/script.js37
1 files changed, 30 insertions, 7 deletions
diff --git a/grapher/script.js b/grapher/script.js
index 4df4516..70be078 100644
--- a/grapher/script.js
+++ b/grapher/script.js
@@ -56,6 +56,7 @@ var mode;
var targ;
var start;
var wirestate;
+var maintouch;
const lastmp = {x:0,y:0};
const graphPos = {x:0,y:0};
@@ -315,9 +316,7 @@ window.onload = async function() {
}
- graph.addEventListener('mousedown', function(e) {
- if ((e.buttons & 1) && !locked) {
- start = performance.now();
+ function clickToWire(e) {start = performance.now();
targ = e.target;
if (e.target.parentElement.matches('.input')) {
if (!e.target.matches('.exec')) delConnections(e.target);
@@ -349,11 +348,21 @@ window.onload = async function() {
else if (e.target == graph) switchID(null, 'selected')
clean = false
+ }
+
+ graph.addEventListener('mousedown', function(e) {
+ if ((e.buttons & 1) && !locked) {
+ clickToWire(e);
+ }
+ });
+ graph.addEventListener('touchstart', function(e) {
+ if (e.touches.length <= 1) {
+ maintouch = e.changedTouches[0];
+ clickToWire(e);
}
});
- rootel.addEventListener("mouseup", e => {
- if ((e.button == 0) && !locked) {
+ function unclickToWire(e) {
let newCon;
switch (mode) {
case 'wire_i-o':
@@ -371,13 +380,23 @@ window.onload = async function() {
connections.push(newCon);
break;
case 'drag':
- if ((performance.now() - start) < 150 && !targ.querySelector('.selUI').matches('#selected')) {
+ if ((performance.now() - start) < 300 && !targ.querySelector('.selUI').matches('#selected')) {
switchID(targ.children[0], 'selected')
}
break;
}
mode = null;
- clean = false
+ clean = false;
+ }
+ rootel.addEventListener("mouseup", e => {
+ if ((e.button == 0) && !locked) {
+ unclickToWire(e);
+ }
+ });
+ graph.addEventListener('touchend', e => {
+ if (e.changedTouches[0] == maintouch) {
+ maintouch = null;
+ unclickToWire(e);
}
});
@@ -409,6 +428,10 @@ window.onload = async function() {
if (mode)
clean = false
});
+ rootel.addEventListener('touchdrag', e => {
+ lastmp.x = e.changedTouches[0].clientX;
+ lastmp.y = e.changedTouches[0].clientY;
+ })
root.addEventListener("mousemove", e => {