From 9d532a82d974541f4ed63485ad72bd1feb196014 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Wed, 11 Oct 2023 02:18:18 +0200 Subject: [PATCH] Slider: fix callback running prematurely --- modules/Slider.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/Slider.js b/modules/Slider.js index 198b2d0f8..856c6bed5 100644 --- a/modules/Slider.js +++ b/modules/Slider.js @@ -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}; } } - if (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) + 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); o.f.draw&&o.f.draw(o.v.level); } + o.v.cbObj = null; o.v.prevLevel = o.v.level; o.v.ebLast = e.b; }