From 6c9a317b3ba6acf39ca737e6534488744a8d0f99 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 4 Mar 2025 15:37:13 +0800 Subject: [PATCH] scrollbar: Fix scroll to show scrollbar. (#681) Fix #624 was broke scroll to show behaviors. --- crates/story/src/scrollable_story.rs | 2 +- crates/ui/src/scroll/scrollbar.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/story/src/scrollable_story.rs b/crates/story/src/scrollable_story.rs index fd4ca2ab..eceb1103 100644 --- a/crates/story/src/scrollable_story.rs +++ b/crates/story/src/scrollable_story.rs @@ -202,7 +202,7 @@ impl Render for ScrollableStory { .gap_4() .child(self.render_buttons(cx)) .child( - div().w_full().flex_1().child( + div().w_full().flex_1().min_h_64().child( div().relative().size_full().child( v_flex() .id("test-0") diff --git a/crates/ui/src/scroll/scrollbar.rs b/crates/ui/src/scroll/scrollbar.rs index 3fa3bdc3..75087246 100644 --- a/crates/ui/src/scroll/scrollbar.rs +++ b/crates/ui/src/scroll/scrollbar.rs @@ -132,8 +132,10 @@ impl ScrollbarState { fn with_hovered_on_thumb(&self, axis: Option) -> Self { let mut state = *self; state.hovered_on_thumb = axis; - if axis.is_some() { - state.last_scroll_time = Some(std::time::Instant::now()); + if self.is_scrollbar_visible() { + if axis.is_some() { + state.last_scroll_time = Some(std::time::Instant::now()); + } } state }