Merge pull request #2584 from iced-rs/fix/scrollable-transactions

Fix `scrollable` transactions when `on_scroll` is not set
This commit is contained in:
Héctor Ramón 2024-09-18 21:54:16 +02:00 committed by GitHub
commit fc722f1356
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -760,13 +760,17 @@ where
content_bounds, content_bounds,
); );
if notify_scroll( let has_scrolled = notify_scroll(
state, state,
&self.on_scroll, &self.on_scroll,
bounds, bounds,
content_bounds, content_bounds,
shell, shell,
) { );
let in_transaction = state.last_scrolled.is_some();
if has_scrolled || in_transaction {
event::Status::Captured event::Status::Captured
} else { } else {
event::Status::Ignored event::Status::Ignored
@ -1194,11 +1198,6 @@ fn notify_viewport<Message>(
return false; return false;
} }
let Some(on_scroll) = on_scroll else {
state.last_notified = None;
return false;
};
let viewport = Viewport { let viewport = Viewport {
offset_x: state.offset_x, offset_x: state.offset_x,
offset_y: state.offset_y, offset_y: state.offset_y,
@ -1229,9 +1228,12 @@ fn notify_viewport<Message>(
} }
} }
shell.publish(on_scroll(viewport));
state.last_notified = Some(viewport); state.last_notified = Some(viewport);
if let Some(on_scroll) = on_scroll {
shell.publish(on_scroll(viewport));
}
true true
} }