Skip to content

Commit

Permalink
[Rust - agx] Model how much out-of-bounds content can be scrolled int…
Browse files Browse the repository at this point in the history
…o the viewport
  • Loading branch information
codyd51 committed Mar 23, 2024
1 parent 0ec5da0 commit f20e642
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rust_programs/libgui/src/scroll_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,17 @@ impl UIElement for ScrollView {
}
};
scroll_offset.y += delta_z * scroll_step;

// Don't allow the user to scroll such that the entire content view is above the viewport.
//
// To give a good sense of interactivity, allow the user to scroll such that *half* of the
// bottommost content is above the viewport.
let scrollable_region = Rect::from_parts(
content_frame.origin,
scrollable_region_size(self.layer.frame().size, content_frame.size),
);
dbg!(delta_z, scroll_offset, scrollable_region);

// Would this exceed the visible content frame?
// If so, don't allow the user to scroll there.
// TODO(PT): Eventually, we could have some kind of attribute to control whether the user is allowed to scroll
Expand Down

0 comments on commit f20e642

Please sign in to comment.