Skip to content
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

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

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

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.
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-scrollview ScrollView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android 🤖
Projects
None yet
4 participants