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

This commit is contained in:
ymh-masuda
2024-05-27 14:13:34 +09:00
committed by GitHub
parent 63edb43d44
commit ba8642bbc8
+4 -1
View File
@@ -474,7 +474,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.*/