Browse Source

fix: DataGrid scroll should behave the same as ScrollViewer (#12787)

if the user holds [Shift], we need to swap e.Delta (e.g. on Windows) if not already done by the OS (e.g. using Mac).
pull/12804/head
Tim 3 years ago
committed by GitHub
parent
commit
341dcce179
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/Avalonia.Controls.DataGrid/DataGrid.cs

11
src/Avalonia.Controls.DataGrid/DataGrid.cs

@ -2285,7 +2285,16 @@ namespace Avalonia.Controls
/// <param name="e">PointerWheelEventArgs</param>
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
{
if(UpdateScroll(e.Delta * DATAGRID_mouseWheelDelta))
var delta = 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.
if (e.KeyModifiers == KeyModifiers.Shift && MathUtilities.IsZero(delta.X))
{
delta = new Vector(delta.Y, delta.X);
}
if(UpdateScroll(delta * DATAGRID_mouseWheelDelta))
{
e.Handled = true;
}

Loading…
Cancel
Save