diff --git a/apps/calculator/app.js b/apps/calculator/app.js index 3a8486452..571a5b27f 100644 --- a/apps/calculator/app.js +++ b/apps/calculator/app.js @@ -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(); } }); }