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

[ScrollViewerPresenter] Fix rtl scroll (#16667) #17714

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ private void OnScrollGesture(object? sender, ScrollGestureEventArgs e)
Vector delta = default;
if (isLogical)
_activeLogicalGestureScrolls?.TryGetValue(e.Id, out delta);
delta += e.Delta;
delta += CheckFlowDirection(e.Delta);

if (isLogical && scrollable is object)
{
Expand Down Expand Up @@ -665,7 +665,7 @@ protected override void OnPointerWheelChanged(PointerWheelEventArgs e)

var x = Offset.X;
var y = Offset.Y;
var delta = e.Delta;
var delta = CheckFlowDirection(e.Delta);

// KeyModifiers.Shift should scroll in horizontal direction. This does not work on every platform.
// If Shift-Key is pressed and X is close to 0 we swap the Vector.
Expand Down Expand Up @@ -1065,5 +1065,14 @@ private static (double previous, double next) FindNearestSnapPoint(IReadOnlyList

return snapPointsInfo;
}

private Vector CheckFlowDirection(Vector delta)
{
if (FlowDirection == Media.FlowDirection.RightToLeft)
{
return delta.WithX(-delta.X);
}
return delta;
}
}
}
Loading