-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Clamp scroll position within bounds in the ui/scroll.rs example
#22327
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
Conversation
|
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
ui/scroll.rs example
alice-i-cecile
left a comment
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.
Sensible fix, but a comment on the math would probably be useful for readers.
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.
Very sleepy but isn't the scroll position clamped during layout anyway, why is this necessary?
There is something wrong though somewhere because I just tried adding scrollbars to the example and they undershoot now with or without this change. I'll take another look tomorrow.
|
From my testing it only overshoots in two cases:
edit: When creating this PR, I did not test resizing the window. I only tested the first case for which this PR fixed the problem. |
|
Yes, this is the |
|
Maybe it's a change detection bug or something then, where the position isn't updated correctly when the size changes. Part of the purpose of the examples is to help identify bugs, so I'm not sure a work around like this is the right approach. It'd be better I think if you could find a fix for whatever the underlying problem is in the scrollbar implementation itself. |
|
I can't reproduce the problem outside of my bevy project [running on bevy v0.17.3] (I'm using a deeply nested UI node hierarchy where everything uses vmin, vw, vh for sizing, border size, padding, and margin and the font size is also automatically adapted for the current window size). I'm trying to create a MRE with bevy v0.17.3. Afterwards I updated it to the latest commit of bevy and check if the problem still persists. |
|
I closed this PR, because the problem is no longer present in 0.18.0-rc.2. |



Objective
on_scroll_handlerin theui/scroll.rsexample. (This is only a problem in combination with scrollbars. If scrollbars are present they could slightly overshoot.)Solution
Testing
Scrollexample on Ubuntu (Wayland). Scrolling still works. I tested those changes in my own bevy project in combination with scrollbars and this change fixed the problem.