diff --git a/src/widgets/lv_switch.c b/src/widgets/lv_switch.c index dd8979252..b32861043 100644 --- a/src/widgets/lv_switch.c +++ b/src/widgets/lv_switch.c @@ -173,7 +173,7 @@ static void draw_main(lv_event_t * e) /*Draw the knob*/ lv_coord_t anim_value_x = 0; lv_coord_t knob_size = lv_obj_get_height(obj); - lv_coord_t anim_length = obj->coords.x2 - bg_right - obj->coords.x1 - bg_left - knob_size; + lv_coord_t anim_length = lv_area_get_width(&obj->coords) - knob_size; if(LV_SWITCH_IS_ANIMATING(sw)) { /* Use the animation's coordinate */ @@ -190,7 +190,7 @@ static void draw_main(lv_event_t * e) } lv_area_t knob_area; - knob_area.x1 = obj->coords.x1 + bg_left + anim_value_x; + knob_area.x1 = obj->coords.x1 + anim_value_x; knob_area.x2 = knob_area.x1 + knob_size; knob_area.y1 = obj->coords.y1;