fix(scroll): fix jumping on scroll end (#6393)
This commit is contained in:
committed by
GitHub
parent
aea90766a4
commit
e1cc1cb2d7
@@ -440,6 +440,8 @@ void lv_obj_update_snap(lv_obj_t * obj, lv_anim_enable_t anim_en)
|
||||
lv_obj_update_layout(obj);
|
||||
lv_point_t p;
|
||||
lv_indev_scroll_get_snap_dist(obj, &p);
|
||||
if(p.x == LV_COORD_MAX || p.x == LV_COORD_MIN) p.x = 0;
|
||||
if(p.y == LV_COORD_MAX || p.y == LV_COORD_MIN) p.y = 0;
|
||||
lv_obj_scroll_by(obj, p.x, p.y, anim_en);
|
||||
}
|
||||
|
||||
|
||||
@@ -487,6 +487,11 @@ static void init_scroll_limits(lv_indev_t * indev)
|
||||
}
|
||||
}
|
||||
|
||||
/*`find_snap_point_x/y()` return LV_COORD_MAX is not snap point was found,
|
||||
*but x1/y1 should be small. */
|
||||
if(indev->pointer.scroll_area.x1 == LV_COORD_MAX) indev->pointer.scroll_area.x1 = LV_COORD_MIN;
|
||||
if(indev->pointer.scroll_area.y1 == LV_COORD_MAX) indev->pointer.scroll_area.y1 = LV_COORD_MIN;
|
||||
|
||||
/*Allow scrolling on the edges. It will be reverted to the edge due to snapping anyway*/
|
||||
if(indev->pointer.scroll_area.x1 == 0) indev->pointer.scroll_area.x1 = LV_COORD_MIN;
|
||||
if(indev->pointer.scroll_area.x2 == 0) indev->pointer.scroll_area.x2 = LV_COORD_MAX;
|
||||
@@ -679,7 +684,7 @@ static int32_t elastic_diff(lv_obj_t * scroll_obj, int32_t diff, int32_t scroll_
|
||||
break;
|
||||
}
|
||||
int32_t d;
|
||||
d = find_snap_point_x(scroll_obj, x, LV_COORD_MAX, 0);
|
||||
d = find_snap_point_x(scroll_obj, x + 1, LV_COORD_MAX, 0);
|
||||
if(d == LV_COORD_MAX) no_more_end_snap = true;
|
||||
d = find_snap_point_x(scroll_obj, LV_COORD_MIN, x, 0);
|
||||
if(d == LV_COORD_MAX) no_more_start_snap = true;
|
||||
|
||||
Reference in New Issue
Block a user