Change to swipe events from drag

pull/2219/head
thyttan 2022-11-03 19:15:28 +01:00 committed by GitHub
parent e57543bd48
commit 6d63552f46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 18 deletions

View File

@ -402,7 +402,7 @@ if (process.env.HWVERSION==1) {
swipeEnabled = false;
drawGlobal();
} else { // touchscreen?
setWatch(_ => {load();}, BTN1, {edge:"falling"}); // Exit with a short press to physical button
setWatch(_ => {load();}, BTN1, {edge:'falling'}); // Exit with a short press to physical button
selected = "NONE";
swipeEnabled = true;
prepareScreen(numbers, numbersGrid, COLORS.DEFAULT);
@ -420,23 +420,18 @@ if (process.env.HWVERSION==1) {
}
}
});
var lastX = 0, lastY = 0;
Bangle.on('drag', (e) => {
if (!e.b) {
if (lastX > 50) { // right
drawSpecials();
} else if (lastX < -50) { // left
drawOperators();
} else if (lastY > 50) { // down
drawNumbers();
} else if (lastY < -50) { // up
drawNumbers();
}
lastX = 0;
lastY = 0;
} else {
lastX = lastX + e.dx;
lastY = lastY + e.dy;
Bangle.on('swipe', (LR, UD) => {
if (LR == 1) { // right
drawSpecials();
}
if (LR == -1) { // left
drawOperators();
}
if (UD == 1) { // down
drawNumbers();
}
if (UD == -1) { // up
drawNumbers();
}
});
}