-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
func (s *Scroll) ScrollToBottom() not scrolling #2917
Comments
Do you experience the same thing using the |
I haven't tried with table. That other post is confusing as they simply said: |
Indeed, it is kind of strange. |
I wonder if this relates to whether it is visible or not. |
Since I have a reproducible case and there isn't much code run, I'll try to debug and find out more. |
@andydotxyz I found that func (s *Scroll) updateOffset(deltaX, deltaY float32) bool {
contentWidth := fyne.Max(s.Content.Size().Width, s.Content.MinSize().Width)
containerWidth := fyne.Max(s.Size().Width, s.MinSize().Width)
contentHeight := fyne.Max(s.Content.Size().Height, s.Content.MinSize().Height)
containerHeight := fyne.Max(s.Size().Height, s.MinSize().Height)
if contentWidth <= containerWidth && contentHeight <= containerHeight {
if s.Offset.X != 0 || s.Offset.Y != 0 {
s.Offset.X = 0
s.Offset.Y = 0
return true
}
return false
}
... If you want this fix I can send a PR. |
Thanks for this. I think that the required change is probably smaller - it only needs to check that the Size() is non-zero, not the content as well. |
Yeah, the Height of MinSize of the scroll container was only 32 - so the Y offset starts out too large. But when we Resize we call Refresh - which calls updateOffset and the code at the end of that does resizing that accounts for a position that goes beyond the limit of the container: s.Offset.X = computeOffset(s.Offset.X, -deltaX, s.Size().Width, s.Content.MinSize().Width)
s.Offset.Y = computeOffset(s.Offset.Y, -deltaY, s.Size().Height, s.Content.MinSize().Height) So that should correct the Y offset to be |
Thanks for the explanation. In terms of the minimum change is it possible to handle the edge case in an if (i.e. if x or y is 0 then use min size) so it is easier to understand than |
Sure, I imagine anything that side-steps the code setting the offset back to 0 would work. I actually thought |
I see your logic - but is this not a special case where 0 (or less) is found but not expected? |
For anyone bumping into this, here's a way to accomplish this (adapted from initial post) but also not scroll unnecessarily if the size is OK already , so you can safely call it on every update even if nothing needs to be done. if (scrollContainer.Content.MinSize().Height) > scrollContainer.Size().Height {
scrollContainer.Offset.Y = scrollContainer.Content.MinSize().Height - scrollContainer.Size().Height
scrollContainer.Base.Refresh()
} Would be nice if this was fixed, obviously, but since this is a helper function I can understand why it's not a high priority. |
Thanks, you helped me fixing the issue... |
I had to open a new one because I made an error |
Describe the bug:
I used
ScrollToBottom
and found it didn't actually scroll to the bottom at all. I was able to work around the issue by calling a couple of the lines thatScrollToBottom
calls without the unnecessary stuff:To Reproduce:
Here is the code that creates a container with scrollable text. Using scrollable.ScrollToBottom() didn't work for me (it loads scrolled to the top).
Device (please complete the following information):
The text was updated successfully, but these errors were encountered: