Slider: fix callback running prematurely

master
thyttan 2023-10-11 02:18:18 +02:00
parent 962d87442e
commit 9d532a82d9
1 changed files with 3 additions and 2 deletions

View File

@ -130,10 +130,11 @@ try { // For making it possiblie to run the test app in the following catch stat
o.v.cbObj = {mode:"incr", value:incr}; o.v.cbObj = {mode:"incr", value:incr};
} }
} }
if (o.v.level!==o.v.prevLevel || o.v.level===0 || o.v.level===o.c.steps) { if (o.v.cbObj && (o.v.level!==o.v.prevLevel||o.v.level===0||o.v.level===o.c.steps)) {
cb(o.v.cbObj.mode, o.v.cbObj.value); // FIXME: Can cause error when using "incr" since it's not sure that o.v.cbObj has been initialized thanks to how the while-logic above works. (Can also do callback with faulty feedback since it didn't update) cb(o.v.cbObj.mode, o.v.cbObj.value);
o.f.draw&&o.f.draw(o.v.level); o.f.draw&&o.f.draw(o.v.level);
} }
o.v.cbObj = null;
o.v.prevLevel = o.v.level; o.v.prevLevel = o.v.level;
o.v.ebLast = e.b; o.v.ebLast = e.b;
} }