Skip to content

Comments

ScrollX and ScrollY values at the ScrollView.Scrolled event are not consistent in ScrollOrientation.Both mode#26931

Merged
jfversluis merged 9 commits intodotnet:mainfrom
SuthiYuvaraj:26747-fix
Jan 24, 2025
Merged

ScrollX and ScrollY values at the ScrollView.Scrolled event are not consistent in ScrollOrientation.Both mode#26931
jfversluis merged 9 commits intodotnet:mainfrom
SuthiYuvaraj:26747-fix

Conversation

@SuthiYuvaraj
Copy link
Contributor

Root Cause:

The issue occurs in the ScrollView when using "Both" scroll mode, where the ScrollX and ScrollY values were not consistently retained during consecutive scroll actions. This inconsistency arises because the framework's ScrollChanged event does not always propagate the correct values for both horizontal and vertical scroll axes. The ScrollView’s internal behavior was resetting the scroll positions incorrectly when switching between horizontal and vertical scrolling, especially in "Both" orientation mode.

Description of Change:

To resolve the issue, the following changes were made:

  • Horizontal Scroll Position Fix: A new property, HorizontalScrollOffset, was added to directly retrieve the horizontal scroll position from the native _hScrollView instance, ensuring the correct value for ScrollX is consistently used.
  • Vertical Scroll Position Fix: The vertical scroll position (ScrollY) is now retrieved directly from PlatformView.ScrollY, ensuring the correct scroll position is retained during horizontal scrolling actions.

Fix Reference:

https://github.com/xamarin/Xamarin.Forms/blob/2f8f4864a4d289dc89a6228e2ca9d6a49993e365/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs#L315

Issue fixed:

Fixes #26747

Output Video

Before Issue Fix After Issue Fix
withoutfix.mov
withfix.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jan 3, 2025
@karthikraja-arumugam karthikraja-arumugam added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jan 3, 2025
@SuthiYuvaraj SuthiYuvaraj marked this pull request as ready for review January 3, 2025 10:13
@SuthiYuvaraj SuthiYuvaraj requested a review from a team as a code owner January 3, 2025 10:13
@rmarinho
Copy link
Member

rmarinho commented Jan 3, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Removed redundant labels and check logic from Bugzilla41415Test to simplify the test case also it is getting failed in CI windows machine.
@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jfversluis jfversluis merged commit 397e17b into dotnet:main Jan 24, 2025
104 checks passed
@jfversluis jfversluis added this to the .NET 9 SR4 milestone Jan 24, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-scrollview ScrollView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] ScrollX and ScrollY values from ScrollView Scrolled event reset unexpectedly when scrolling in alternate directions

6 participants