From 7f6f5549fe6d1bd03772c13e96f9d92a26660929 Mon Sep 17 00:00:00 2001 From: alyx Date: Mon, 6 Jun 2022 18:16:16 +0000 Subject: goofy bits of gass and such, more typing --- grapher/script.js | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'grapher/script.js') 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 => { -- cgit v1.2.3-54-g00ecf