setuichange: throw if custom drag on some modes

If custom drag handler is added together with mode updown or leftright
throw an exception.
pull/3563/head
thyttan 2024-09-10 15:59:36 +02:00
parent 4d8c46ba51
commit c757b85760
3 changed files with 5 additions and 1 deletions

View File

@ -1,3 +1,5 @@
0.01: New App!
0.02: Fix case where we tried to push to Bangle.btnWatches but it wasn't
defined.
0.03: Throw exception if trying to add custom drag handler on mode updown and
leftright.

View File

@ -39,6 +39,7 @@ Bangle.setUI = (function(mode, cb) {
try{Bangle.buzz(30);}catch(e){}
}
if (mode=="updown") {
if (options.drag) throw new Error("Custom drag handler not supported in mode updown!")
var dy = 0;
Bangle.dragHandler = e=>{
dy += e.dy;
@ -55,6 +56,7 @@ Bangle.setUI = (function(mode, cb) {
setWatch(function() { b();cb(); }, BTN1, {repeat:1, edge:"rising"}),
];
} else if (mode=="leftright") {
if (options.drag) throw new Error("Custom drag handler not supported in mode leftright!")
var dx = 0;
Bangle.dragHandler = e=>{
dx += e.dx;

View File

@ -1,6 +1,6 @@
{ "id": "setuichange",
"name": "SetUI Proposals preview",
"version":"0.02",
"version":"0.03",
"description": "Try out potential future changes to `Bangle.setUI`. Makes hardware button interaction snappier. Makes it possible to set custom event handlers on any type/mode, not just `\"custom\"`. Please provide feedback - see `Read more...` below.",
"icon": "app.png",
"tags": "",