Skip to content

Commit

Permalink
fix (scroll) do not send unnecessary scroll end events
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Jun 14, 2021
1 parent 25acaf4 commit 3ce5226
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/core/lv_obj_scroll.c
Expand Up @@ -289,12 +289,14 @@ void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable
}
} else {
/*Remove pending animations*/
lv_res_t res;
res = lv_event_send(obj, LV_EVENT_SCROLL_END, NULL);
if(res != LV_RES_OK) return;
lv_anim_del(obj, scroll_y_anim);
lv_anim_del(obj, scroll_x_anim);
bool y_del = lv_anim_del(obj, scroll_y_anim);
bool x_del = lv_anim_del(obj, scroll_x_anim);
scroll_by_raw(obj, x, y);
if(y_del || x_del) {
lv_res_t res;
res = lv_event_send(obj, LV_EVENT_SCROLL_END, NULL);
if(res != LV_RES_OK) return;
}
}
}

Expand Down Expand Up @@ -700,11 +702,13 @@ static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_p
}

/*Remove any pending scroll animations.*/
lv_res_t res;
res = lv_event_send(parent, LV_EVENT_SCROLL_END, NULL);
if(res != LV_RES_OK) return;
lv_anim_del(parent, scroll_x_anim);
lv_anim_del(parent, scroll_y_anim);
bool y_del = lv_anim_del(parent, scroll_y_anim);
bool x_del = lv_anim_del(parent, scroll_x_anim);
if(y_del || x_del) {
lv_res_t res;
res = lv_event_send(parent, LV_EVENT_SCROLL_END, NULL);
if(res != LV_RES_OK) return;
}

if((scroll_dir & LV_DIR_LEFT) == 0 && x_scroll < 0) x_scroll = 0;
if((scroll_dir & LV_DIR_RIGHT) == 0 && x_scroll > 0) x_scroll = 0;
Expand Down

0 comments on commit 3ce5226

Please sign in to comment.