From 7d5aa89c2194a03e78b7144e2f9047393e73e25f Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Tue, 3 May 2022 12:54:34 +0100 Subject: [PATCH] Update app.js Fix layout button uninitialised if timer already running. --- apps/smpltmr/app.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/smpltmr/app.js b/apps/smpltmr/app.js index 1583663ba..b7511724a 100644 --- a/apps/smpltmr/app.js +++ b/apps/smpltmr/app.js @@ -47,14 +47,15 @@ function onDrag(event) { } function onTouch(button, xy) { - var touchMidpoint = timePickerLayout.hours.y + timePickerLayout.hours.h/2; - var diff = 0; - Bangle.buzz(40, 0.3); - if (xy.y > timePickerLayout.btnStart.y) { + if (xy.y > (timePickerLayout.btnStart.y||timerLayout.btnStart.y)) { + Bangle.buzz(40, 0.3); onButton(); return; } if (!timerRunning()) { + var touchMidpoint = timePickerLayout.hours.y + timePickerLayout.hours.h/2; + var diff = 0; + Bangle.buzz(40, 0.3); if (xy.y > 24 && xy.y < touchMidpoint - 10) { diff = 1; } else if (xy.y > touchMidpoint + 10 && xy.y < timePickerLayout.btnStart.y) { @@ -159,7 +160,7 @@ var timePickerLayout = new Layout({ var timerLayout = new Layout({ type:"v", c: [ {type:"txt", font:"22%", label:"0:00", id:"timer", fillx:1, filly:1 }, - {type:"btn", src:imgPause, cb: l=>timerStop(), fillx:1 } + {type:"btn", src:imgPause, id:"btnStart", cb: l=>timerStop(), fillx:1 } ], filly:1 });