1
0
Fork 0

SliderInput: add function to auto progress

making it possible to track progress in e.g. a song.
master
thyttan 2023-08-27 12:17:57 +02:00
parent 644d23a511
commit 87a8593b04
1 changed files with 16 additions and 4 deletions

View File

@ -23,6 +23,7 @@ const LAZY = conf.lazy===false?false:true;
const ROUND = conf.rounded?40:0;
const PROPAGATE = conf.propagateDrag || false;
const IMMEDIATE_DRAW = conf.immediateDraw || false;
const AUTO_PROGRESS = conf.autoProgress || false;
const STEP_SIZE = HEIGHT/STEPS;
@ -37,8 +38,8 @@ if (ROTATE) {
}
// Initialize the level
let level;
let prevLevel = conf.currLevel || STEPS/2;
let level = conf.currLevel || STEPS/2;
let prevLevel;
let firstRun = true;
let ebLast = 0;
@ -90,7 +91,7 @@ let dragSlider = e=>{
else { dy+=32; incr = -1;}
Bangle.buzz(20);
level = Math.min(Math.max(prevLevel-incr,0),STEPS);
level = Math.min(Math.max(level-incr,0),STEPS);
cb("incr",incr);
draw(level);
}
@ -133,7 +134,18 @@ if (TIMEOUT) timeout = setTimeout(remove, 1000*TIMEOUT);
let dy = 0;
g.reset();
Bangle.prependListener('drag', dragSlider);
if (IMMEDIATE_DRAW) draw(prevLevel);
if (IMMEDIATE_DRAW) draw(level);
if (AUTO_PROGRESS) {
draw(level);
let autoUpdate = ()=>{
level = level?level+1:0;
draw(level);
if (level==STEPS) {clearInterval(autoInterval); return;}
};
let autoInterval;
autoInterval = setInterval(autoUpdate,1000);
}
}
} catch (e) {