mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
fix(slider): find the nearest value on click instead of floor
fixes: #3690
This commit is contained in:
parent
d89e732634
commit
f1d69ca044
@ -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);
|
new_value = p.x - (obj->coords.x1 + bg_left);
|
||||||
}
|
}
|
||||||
if(indic_w) {
|
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;
|
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*/
|
/*Make the point relative to the indicator*/
|
||||||
new_value = p.y - (obj->coords.y2 + bg_bottom);
|
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;
|
new_value += slider->bar.min_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user