forked from FOSS/BangleApps
Merge pull request #1487 from hughbarney/master
Stopwatch touch - adjust on touch for x,y outside the dimensions of g.getW/Hmaster
commit
ea8b52bdd2
|
@ -1 +1,2 @@
|
||||||
0.01: first release
|
0.01: first release
|
||||||
|
0.02: Adjust for touch events outside of screen g dimensions
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "stopwatch",
|
"id": "stopwatch",
|
||||||
"name": "Stopwatch Touch",
|
"name": "Stopwatch Touch",
|
||||||
"version": "0.01",
|
"version": "0.02",
|
||||||
"description": "A touch based stop watch for Bangle JS 2",
|
"description": "A touch based stop watch for Bangle JS 2",
|
||||||
"icon": "stopwatch.png",
|
"icon": "stopwatch.png",
|
||||||
"screenshots": [{"url":"screenshot1.png"},{"url":"screenshot2.png"},{"url":"screenshot3.png"}],
|
"screenshots": [{"url":"screenshot1.png"},{"url":"screenshot2.png"},{"url":"screenshot3.png"}],
|
||||||
|
|
|
@ -185,17 +185,27 @@ resetBtn.setImage(pause_img);
|
||||||
|
|
||||||
|
|
||||||
Bangle.on('touch', function(button, xy) {
|
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
|
// 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
|
// 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
|
// 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
|
// 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
|
// Stop updates when LCD is off, restart when on
|
||||||
|
|
Loading…
Reference in New Issue