Skip to content
Closed
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
6 changes: 4 additions & 2 deletions examples/ui/scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ fn on_scroll_handler(
};

if !max {
scroll_position.x += delta.x;
// Update the x portion of the scroll position with the scroll delta and clamp the value between 0.0 and the max x offset
scroll_position.x = (scroll_position.x + delta.x).max(0.0).min(max_offset.x);
// Consume the X portion of the scroll delta.
delta.x = 0.;
}
Expand All @@ -93,7 +94,8 @@ fn on_scroll_handler(
};

if !max {
scroll_position.y += delta.y;
// Update the y portion of the scroll position with the scroll delta and clamp the value between 0.0 and the max y offset
scroll_position.y = (scroll_position.y + delta.y).max(0.0).min(max_offset.y);
// Consume the Y portion of the scroll delta.
delta.y = 0.;
}
Expand Down