diff --git a/apps/stopwatch/ChangeLog b/apps/stopwatch/ChangeLog index 9db0e26c5..104fce19d 100644 --- a/apps/stopwatch/ChangeLog +++ b/apps/stopwatch/ChangeLog @@ -1 +1,2 @@ 0.01: first release +0.02: Adjust for touch events outside of screen g dimensions diff --git a/apps/stopwatch/metadata.json b/apps/stopwatch/metadata.json index e72d85af1..cc13ec92f 100644 --- a/apps/stopwatch/metadata.json +++ b/apps/stopwatch/metadata.json @@ -1,7 +1,7 @@ { "id": "stopwatch", "name": "Stopwatch Touch", - "version": "0.01", + "version": "0.02", "description": "A touch based stop watch for Bangle JS 2", "icon": "stopwatch.png", "screenshots": [{"url":"screenshot1.png"},{"url":"screenshot2.png"},{"url":"screenshot3.png"}], diff --git a/apps/stopwatch/stopwatch.app.js b/apps/stopwatch/stopwatch.app.js index 48d4f26ea..e2be95451 100644 --- a/apps/stopwatch/stopwatch.app.js +++ b/apps/stopwatch/stopwatch.app.js @@ -185,17 +185,27 @@ resetBtn.setImage(pause_img); Bangle.on('touch', function(button, xy) { + var x = xy.x; + var y = xy.y; + + // adjust for outside the dimension of the screen + // http://forum.espruino.com/conversations/371867/#comment16406025 + if (y > h) y = h; + if (y < 0) y = 0; + if (x > w) x = w; + if (x < 0) x = 0; + // not running, and reset - if (!running && tCurrent == tTotal && bigPlayPauseBtn.check(xy.x, xy.y)) return; + if (!running && tCurrent == tTotal && bigPlayPauseBtn.check(x, y)) return; // paused and hit play - if (!running && tCurrent != tTotal && smallPlayPauseBtn.check(xy.x, xy.y)) return; + if (!running && tCurrent != tTotal && smallPlayPauseBtn.check(x, y)) return; // paused and press reset - if (!running && tCurrent != tTotal && resetBtn.check(xy.x, xy.y)) return; + if (!running && tCurrent != tTotal && resetBtn.check(x, y)) return; // must be running - if (running && bigPlayPauseBtn.check(xy.x, xy.y)) return; + if (running && bigPlayPauseBtn.check(x, y)) return; }); // Stop updates when LCD is off, restart when on