fix(slider): find the nearest value on click instead of floor

fixes: #3690
This commit is contained in:
Gabor Kiss-Vamosi
2022-09-19 09:53:53 +02:00
parent d89e732634
commit f1d69ca044
+2 -2
View File
@@ -213,7 +213,7 @@ static void lv_slider_event(const lv_obj_class_t * class_p, lv_event_t * e)
new_value = p.x - (obj->coords.x1 + bg_left);
}
if(indic_w) {
new_value = (new_value * range) / indic_w;
new_value = (new_value * range + indic_w / 2) / indic_w;
new_value += slider->bar.min_value;
}
}
@@ -225,7 +225,7 @@ static void lv_slider_event(const lv_obj_class_t * class_p, lv_event_t * e)
/*Make the point relative to the indicator*/
new_value = p.y - (obj->coords.y2 + bg_bottom);
new_value = (-new_value * range) / indic_h;
new_value = (-new_value * range + indic_h / 2) / indic_h;
new_value += slider->bar.min_value;
}