Update app.js

Fix layout button uninitialised if timer already running.
pull/1788/head
sir-indy 2022-05-03 12:54:34 +01:00 committed by GitHub
parent aad0a48a88
commit 7d5aa89c21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -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
});