-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add scroll_to
operation
#1796
Add scroll_to
operation
#1796
Conversation
pub struct CurrentOffset { | ||
/// The [`AbsoluteOffset`] of a [`Scrollable`] | ||
pub absolute: AbsoluteOffset, | ||
/// The [`RelativeOffset`] of a [`Scrollable`] | ||
pub relative: RelativeOffset, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some redundancy here.
I think it'd be better to have a Window
or Viewport
type with the already existing private Offset
, the content bounds, and the scrollable bounds.
Then we can expose relative_offset
and absolute_offset
methods in this type that compute the actual values from a single source of truth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion 6ad5e03
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
I have made a change to compare the absolute offsets as well in notify_on_scroll
, since it's theoretically possible that the relative offset stays the same but the absolute offset doesn't (e.g. if the bounds of the Scrollable
change while scrolling). See 8a71140.
I think we can merge! 🚢
Supersedes #1795
Exposes a new
scroll_to
operation to allow scrolling a scrollable to a desired "absolute" offset.