Slider:move draw and cb to deduplicate code
parent
944da80186
commit
408990d919
|
|
@ -100,6 +100,7 @@ try { // For making it possiblie to run the test app in the following catch stat
|
|||
if (o.v.timeoutID) {clearTimeout(o.v.timeoutID); o.v.timeoutID = undefined;}
|
||||
if (e.b==0 && !o.v.timeoutID && (o.c.timeout || o.c.timeout===0)) o.v.timeoutID = setTimeout(o.f.remove, 1000*o.c.timeout);
|
||||
|
||||
let cbObj;
|
||||
if (o.c.useMap && o.f.wasOnIndicator(exFirst)) { // If draging starts on the indicator, adjust one-to-one.
|
||||
|
||||
let input = !o.c.horizontal?
|
||||
|
|
@ -109,11 +110,8 @@ try { // For making it possiblie to run the test app in the following catch stat
|
|||
|
||||
o.v.level = Math.min(Math.max(input,0),o.c.steps);
|
||||
|
||||
if (o.v.level != o.v.prevLevel) {
|
||||
cb("map",o.v.level);
|
||||
o.f.draw&&o.f.draw(o.v.level);
|
||||
}
|
||||
o.v.prevLevel = o.v.level;
|
||||
cbObj = {mode:"map", value:o.v.level};
|
||||
|
||||
} else if (o.c.useIncr) { // Heavily inspired by "updown" mode of setUI.
|
||||
|
||||
o.v.dy += o.c.horizontal?-e.dx:e.dy;
|
||||
|
|
@ -126,11 +124,15 @@ try { // For making it possiblie to run the test app in the following catch stat
|
|||
Bangle.buzz(20);
|
||||
|
||||
o.v.level = Math.min(Math.max(o.v.level-incr,0),o.c.steps);
|
||||
cb("incr",incr);
|
||||
|
||||
cbObj = {mode:"incr", value:incr};
|
||||
}
|
||||
}
|
||||
if (o.v.level != o.v.prevLevel) {
|
||||
o.f.draw&&o.f.draw(o.v.level);
|
||||
cb(cbObj.mode, cbObj.value);
|
||||
}
|
||||
o.v.prevLevel = o.v.level;
|
||||
}
|
||||
}
|
||||
o.v.ebLast = e.b;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue