From 3ce5226c9d9db279904c4f076ae77e6e03572e4c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 15 Jun 2021 00:01:55 +0200 Subject: [PATCH] fix (scroll) do not send unnecessary scroll end events --- src/core/lv_obj_scroll.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/core/lv_obj_scroll.c b/src/core/lv_obj_scroll.c index ad1ce474a..b0e5220ba 100644 --- a/src/core/lv_obj_scroll.c +++ b/src/core/lv_obj_scroll.c @@ -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; + } } } @@ -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;