scrollbar: Fix scroll to show mode. (#1381)

Close #1379, this bug is introduced from #1196.
This commit is contained in:
Jason Lee 2025-10-15 13:51:13 +08:00 committed by GitHub
parent 429a4b2858
commit 491bacfd0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -579,6 +579,7 @@ impl Element for Scrollbar {
let state = self.state.clone(); let state = self.state.clone();
let is_always_to_show = cx.theme().scrollbar_show.is_always(); let is_always_to_show = cx.theme().scrollbar_show.is_always();
let is_hover_to_show = cx.theme().scrollbar_show.is_hover();
let is_hovered_on_bar = state.get().hovered_axis == Some(axis); let is_hovered_on_bar = state.get().hovered_axis == Some(axis);
let is_hovered_on_thumb = state.get().hovered_on_thumb == Some(axis); let is_hovered_on_thumb = state.get().hovered_on_thumb == Some(axis);
let is_offset_changed = state.get().last_scroll_offset != self.scroll_handle.offset(); let is_offset_changed = state.get().last_scroll_offset != self.scroll_handle.offset();
@ -586,7 +587,7 @@ impl Element for Scrollbar {
let (thumb_bg, bar_bg, bar_border, thumb_width, inset, radius) = let (thumb_bg, bar_bg, bar_border, thumb_width, inset, radius) =
if state.get().dragged_axis == Some(axis) { if state.get().dragged_axis == Some(axis) {
Self::style_for_active(cx) Self::style_for_active(cx)
} else if is_hovered_on_bar || is_hovered_on_thumb { } else if is_hover_to_show && (is_hovered_on_bar || is_hovered_on_thumb) {
if is_hovered_on_thumb { if is_hovered_on_thumb {
Self::style_for_hovered_thumb(cx) Self::style_for_hovered_thumb(cx)
} else { } else {