fix(roller): avoid divided-by-zero during draw event (#6285) (#6661)

Co-authored-by: ymh-masuda <160470322+ymh-masuda@users.noreply.github.com>
This commit is contained in:
Liam
2024-08-12 08:47:46 -04:00
committed by GitHub
parent 533386b030
commit fe821204a7

View File

@@ -473,7 +473,10 @@ static void draw_main(lv_event_t * e)
/*Proportional position from the middle line.
*Will be 0 for the first option, and 1 for the last option (upscaled by << 14)*/
label_y_prop = (label_y_prop << 14) / (lv_obj_get_height(label) - normal_label_font->line_height);
int32_t remain_h = lv_obj_get_height(label) - normal_label_font->line_height;
if(remain_h > 0) {
label_y_prop = (label_y_prop << 14) / remain_h;
}
/*We don't want the selected label start and end exactly where the normal label is as
*a larger font won't centered on selected area.*/