From 7944a1d9150cb68209d68b6306c0899b0f13addf Mon Sep 17 00:00:00 2001 From: lixianjing Date: Tue, 8 Jun 2021 16:34:34 +0800 Subject: [PATCH] improve hscrollable --- docs/changes.md | 1 + src/base/hscrollable.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/changes.md b/docs/changes.md index 12b4cf060..74ce84c24 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -4,6 +4,7 @@ * 完善编译脚本(感谢兆坤提供补丁) * 完善slide view,垂直slide view用上下键切换页面。 * 完善slide view,处理滑动太快,中间没有move事件的问题。 + * 修复hscrollable,点击边缘控件没有滚动效果的问题(感谢智明提供补丁) 2021/06/07 * 重构和完善文档。 diff --git a/src/base/hscrollable.c b/src/base/hscrollable.c index fdcd76411..9cc5bab03 100644 --- a/src/base/hscrollable.c +++ b/src/base/hscrollable.c @@ -274,8 +274,13 @@ ret_t hscrollable_set_prop(hscrollable_t* hscrollable, const char* name, const v } else if (tk_str_eq(name, WIDGET_PROP_XSLIDABLE)) { return RET_OK; } else if (tk_str_eq(name, WIDGET_PROP_XOFFSET)) { - hscrollable->xoffset = value_int(v); - widget_invalidate_force(hscrollable_get_widget(hscrollable), NULL); + if (hscrollable->wa != NULL) { + hscrollable->xoffset = value_int(v); + widget_invalidate_force(hscrollable_get_widget(hscrollable), NULL); + } else { + hscrollable->xoffset_end = value_int(v); + hscrollable_scroll_to(hscrollable, hscrollable->xoffset_end, 300); + } return RET_OK; } else if (tk_str_eq(name, WIDGET_PROP_YOFFSET)) { return RET_OK;