touch events

This commit is contained in:
ntr 2019-04-07 14:02:20 +10:00
parent 429fdcbd0e
commit 2724ba8283
2 changed files with 20 additions and 5 deletions

View File

@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "parcel index.html --port 40080 --no-source-maps",
"start": "parcel index.html --host 0.0.0.0 --port 40080 --no-source-maps",
"build": "rm -rf dist && parcel build index.html",
"lint": "eslint --fix --ext .jsx src/",
"test": "echo \"Error: no test specified\" && exit 1"

View File

@ -50,10 +50,13 @@ function Vbox(args) {
function vboxTouchEnd(e, i, j) {
if (vboxTimer) {
clearTimeout(vboxTimer);
if (free[i][j]) setInfo('item', free[i][j]);
}
return true;
}
function vboxTouchMove(e) {
if (vboxTimer) clearTimeout(vboxTimer);
e.stopPropagation();
e.preventDefault();
return true;
}
@ -63,6 +66,7 @@ function Vbox(args) {
key={j}
onTouchStart={e => vboxTouchStart(e, i, j)}
onTouchEnd={e => vboxTouchEnd(e, i, j)}
onTouchMove={e => vboxTouchMove(e)}
onClick={() => { if (c) return setInfo('item', c); }}
onDblClick={() => sendVboxAccept(j, i) }
@ -103,14 +107,25 @@ function Vbox(args) {
if (reclaiming && i) sendVboxReclaim(i);
else if (vbox.bound[i]) setActiveVar(i);
}
return true;
}
function boundTouchMove(e) {
if (boundTimer) clearTimeout(boundTimer);
e.stopPropagation();
e.preventDefault();
return true;
}
function boundClick(e, i) {
if (reclaiming && i) sendVboxReclaim(i);
else if (vbox.bound[i]) setActiveVar(i);
else if (vbox.bound[i]) {
const insert = combiner.findIndex(j => j === null);
if (insert === -1) return setCombiner([i, null, null]);
combiner[insert] = i;
boundTimer = null;
return setCombiner(combiner);
}
return false;
}
const boundTds = range(0, 9).map(i => {