diff options
author | 2024-09-18 21:45:25 +0200 | |
---|---|---|
committer | 2024-09-18 21:45:25 +0200 | |
commit | 11ac9125491c4d743c393857445b9b67ea5a437a (patch) | |
tree | c62e50e447d595c824b22e707432d12674c2df15 | |
parent | 035d4e37d5a1c818aa134b8c99b31d635a7b8996 (diff) | |
download | iced-11ac9125491c4d743c393857445b9b67ea5a437a.tar.gz iced-11ac9125491c4d743c393857445b9b67ea5a437a.tar.bz2 iced-11ac9125491c4d743c393857445b9b67ea5a437a.zip |
Fix `scrollable` transactions when `on_scroll` is not set
-rw-r--r-- | widget/src/scrollable.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index af6a3945..b8de66e3 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -760,13 +760,17 @@ where content_bounds, ); - if notify_scroll( + let has_scrolled = notify_scroll( state, &self.on_scroll, bounds, content_bounds, shell, - ) { + ); + + let in_transaction = state.last_scrolled.is_some(); + + if has_scrolled || in_transaction { event::Status::Captured } else { event::Status::Ignored @@ -1194,11 +1198,6 @@ fn notify_viewport<Message>( return false; } - let Some(on_scroll) = on_scroll else { - state.last_notified = None; - return false; - }; - let viewport = Viewport { offset_x: state.offset_x, offset_y: state.offset_y, @@ -1229,9 +1228,12 @@ fn notify_viewport<Message>( } } - shell.publish(on_scroll(viewport)); state.last_notified = Some(viewport); + if let Some(on_scroll) = on_scroll { + shell.publish(on_scroll(viewport)); + } + true } |