Skip to content

Commit

Permalink
Fix rtl scroll (AvaloniaUI#16667)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijklam committed Dec 8, 2024
1 parent 8c88a8e commit aa63c83
Showing 1 changed file with 11 additions and 2 deletions.
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;
}
}
}

0 comments on commit aa63c83

Please sign in to comment.