Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scrollable transactions when on_scroll is not set #2584

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions widget/src/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}

Expand Down
Loading