You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 1, 2024. It is now read-only.
When calling ScrollToAsync on a horizontal ScrollView, the scroll view will scroll to the appropriate X location, however some height adjustments are made when they shouldn't. If there is any padding on the scroll view, it seems to use the padding in its height offset calculation, and therefore positions the scroll view's Y scroll offset incorrectly.
This appears to be a bug introduced with #14926 where the newOffset is calculated like so
It appears that using Margin on the StackLayout behaves differently to using Padding on the ScrollView even though visually they give the same inital layout result.
Steps to Reproduce
Download the sample project
Run on iOS device or simulator
Click the 'click to scroll' button near the top scroll view to make it scroll 200 pixels to the right.
Click the 'click to scroll' button near the bottom scroll view to make it scroll 200 pixels to the right.
Expected Behavior
Both scroll views scroll 200 pixels to the right.
Actual Behavior
The first scroll view scrolls 200 pixels to the right but also scrolls vertically.
The second scroll view scrolls 200 pixels to the right.
Same issue for vertical scrolling. I have padding in ScrollView for right and left {10,0,10,0} and when I do ScrollToAsync to scroll vertically it also scrolls it horizontally to newOffset.X = -20 value, but it should scroll only vertically. I applied your workaround and it did fix, thanks.
+1
Noticed the same behavior, either horizontally or vertically. Using Margin instead of Padding as a workaround indeed fixes the issue.
This can still be a problem in case for example you need to set a specific background color for the scrollview, setting margins will result in empty space around the view. You can place the scrollview inside another container to get around that also, but it would add up useless views just to fix that specific iOS problem.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
When calling
ScrollToAsync
on a horizontalScrollView
, the scroll view will scroll to the appropriate X location, however some height adjustments are made when they shouldn't. If there is any padding on the scroll view, it seems to use the padding in its height offset calculation, and therefore positions the scroll view's Y scroll offset incorrectly.This appears to be a bug introduced with #14926 where the
newOffset
is calculated like soWhen we click the first 'click to scroll' the values before the if are:
and the values after the if are
When we click the second 'click to scroll' the values before the if are:
and the values after the if are
It appears that using
Margin
on theStackLayout
behaves differently to usingPadding
on theScrollView
even though visually they give the same inital layout result.Steps to Reproduce
Expected Behavior
Both scroll views scroll 200 pixels to the right.
Actual Behavior
The first scroll view scrolls 200 pixels to the right but also scrolls vertically.
The second scroll view scrolls 200 pixels to the right.
Basic Information
Environment
Show/Hide Visual Studio info
Build Logs
N/A
Screenshots
Reproduction Link
ScrollViewScrollToTest.zip
Workaround
If you have a
ScrollView
and you want some internal gap don't usePadding
on it but instead useMargin
on its child.The text was updated successfully, but these errors were encountered: