From 1a669a646de11d16ed09ad3e720bd1d136264e91 Mon Sep 17 00:00:00 2001 From: sologeek Date: Tue, 27 Jun 2023 14:37:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(core):=20=F0=9F=90=9B=20scrollable=20update?= =?UTF-8?q?=20content=20size=20or=20view=20size=20need=20update=20offset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/builtin_widgets/scrollable.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/core/src/builtin_widgets/scrollable.rs b/core/src/builtin_widgets/scrollable.rs index 2b5396014..5fa824c60 100644 --- a/core/src/builtin_widgets/scrollable.rs +++ b/core/src/builtin_widgets/scrollable.rs @@ -48,15 +48,26 @@ impl ComposeChild for ScrollableWidget { left_anchor: this.scroll_pos.x, top_anchor: this.scroll_pos.y, } - }} + } + } finally { let_watch!(content.layout_size()) .distinct_until_changed() - .subscribe(move |v| this.content_size = v); + .subscribe(move |v| { + this.content_size = v; + // content size update need to update scroll offset. + let scroll_pos = this.scroll_pos; + this.jump_to(scroll_pos); + }); let_watch!(view.layout_size()) .distinct_until_changed() - .subscribe(move |v| this.page = v); + .subscribe(move |v| { + this.page = v; + // view size update need to update scroll offset. + let scroll_pos = this.scroll_pos; + this.jump_to(scroll_pos); + }); } }