|
|
|
@ -5,6 +5,7 @@ using System.Reactive.Disposables; |
|
|
|
using System.Reactive.Linq; |
|
|
|
using Avalonia.Controls.Primitives; |
|
|
|
using Avalonia.Input; |
|
|
|
using Avalonia.Utilities; |
|
|
|
using Avalonia.VisualTree; |
|
|
|
|
|
|
|
namespace Avalonia.Controls.Presenters |
|
|
|
@ -440,15 +441,23 @@ namespace Avalonia.Controls.Presenters |
|
|
|
if (Extent.Height > Viewport.Height || Extent.Width > Viewport.Width) |
|
|
|
{ |
|
|
|
var scrollable = Child as ILogicalScrollable; |
|
|
|
bool isLogical = scrollable?.IsLogicalScrollEnabled == true; |
|
|
|
var isLogical = scrollable?.IsLogicalScrollEnabled == true; |
|
|
|
|
|
|
|
double x = Offset.X; |
|
|
|
double y = Offset.Y; |
|
|
|
var x = Offset.X; |
|
|
|
var y = Offset.Y; |
|
|
|
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 (Extent.Height > Viewport.Height) |
|
|
|
{ |
|
|
|
double height = isLogical ? scrollable!.ScrollSize.Height : 50; |
|
|
|
y += -e.Delta.Y * height; |
|
|
|
y += -delta.Y * height; |
|
|
|
y = Math.Max(y, 0); |
|
|
|
y = Math.Min(y, Extent.Height - Viewport.Height); |
|
|
|
} |
|
|
|
@ -456,7 +465,7 @@ namespace Avalonia.Controls.Presenters |
|
|
|
if (Extent.Width > Viewport.Width) |
|
|
|
{ |
|
|
|
double width = isLogical ? scrollable!.ScrollSize.Width : 50; |
|
|
|
x += -e.Delta.X * width; |
|
|
|
x += -delta.X * width; |
|
|
|
x = Math.Max(x, 0); |
|
|
|
x = Math.Min(x, Extent.Width - Viewport.Width); |
|
|
|
} |
|
|
|
|