pull/2041/head
Hank 2022-07-12 12:51:37 +02:00
parent efdacb23c0
commit 0aa5d76cbf
1 changed files with 26 additions and 26 deletions

View File

@ -257,37 +257,37 @@ function bjsGetButtonState() {
} }
function initDragEvents() { function initDragEvents() {
Bangle.on("drag", e => { Bangle.on("drag", e => {
if (!drag) { // start dragging if (!drag) { // start dragging
drag = {x: e.x, y: e.y}; drag = {x: e.x, y: e.y};
} else if (!e.b) { // released } else if (!e.b) { // released
const dx = e.x-drag.x, dy = e.y-drag.y; const dx = e.x-drag.x, dy = e.y-drag.y;
drag = null; drag = null;
if (Math.abs(dx)>Math.abs(dy)+10) { if (Math.abs(dx)>Math.abs(dy)+10) {
// horizontal // horizontal
if (dx < dy) { if (dx < dy) {
//console.log("left " + dx + " " + dy); //console.log("left " + dx + " " + dy);
previousDrink(); previousDrink();
} else {
//console.log("right " + dx + " " + dy);
nextDrink();
}
} else if (Math.abs(dy)>Math.abs(dx)+10) {
// vertical
if (dx < dy) {
//console.log("down " + dx + " " + dy);
removeDrink();
} else {
//console.log("up " + dx + " " + dy);
addDrink();
}
} else { } else {
//console.log("right " + dx + " " + dy); //console.log("tap " + e.x + " " + e.y);
nextDrink(); if (e.x > 145 && e.y > 145) {
} resetDrinksFn();
} else if (Math.abs(dy)>Math.abs(dx)+10) { }
// vertical
if (dx < dy) {
//console.log("down " + dx + " " + dy);
removeDrink();
} else {
//console.log("up " + dx + " " + dy);
addDrink();
}
} else {
//console.log("tap " + e.x + " " + e.y);
if (e.x > 145 && e.y > 145) {
resetDrinksFn();
} }
} }
}
} }
); );
} }