diff --git a/src/widgets/slider/lv_slider.c b/src/widgets/slider/lv_slider.c index 64e6ca8e7..cbd5344ad 100644 --- a/src/widgets/slider/lv_slider.c +++ b/src/widgets/slider/lv_slider.c @@ -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; }