Browse Source

Merge pull request #11087 from AvaloniaUI/fixes/thumb-drag-delta

Make thumb drag delta relative to root.
pull/11091/head
Max Katz 4 years ago
committed by GitHub
parent
commit
361c65c01e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Avalonia.Base/Input/PointerEventArgs.cs
  2. 6
      src/Avalonia.Controls/Primitives/Thumb.cs

4
src/Avalonia.Base/Input/PointerEventArgs.cs

@ -77,14 +77,14 @@ namespace Avalonia.Input
/// <summary>
/// Gets the pointer position relative to a control.
/// </summary>
/// <param name="relativeTo">The control.</param>
/// <param name="relativeTo">The visual whose coordinate system to use. Pass null for toplevel coordinate system</param>
/// <returns>The pointer position in the control's coordinates.</returns>
public Point GetPosition(Visual? relativeTo) => GetPosition(_rootVisualPosition, relativeTo);
/// <summary>
/// Returns the PointerPoint associated with the current event
/// </summary>
/// <param name="relativeTo">The visual which coordinate system to use. Pass null for toplevel coordinate system</param>
/// <param name="relativeTo">The visual whose coordinate system to use. Pass null for toplevel coordinate system</param>
/// <returns></returns>
public PointerPoint GetCurrentPoint(Visual? relativeTo)
=> new PointerPoint(Pointer, GetPosition(relativeTo), _properties);

6
src/Avalonia.Controls/Primitives/Thumb.cs

@ -85,7 +85,7 @@ namespace Avalonia.Controls.Primitives
{
if (_lastPoint.HasValue)
{
var point = e.GetPosition(this.GetVisualParent());
var point = e.GetPosition(null);
var ev = new VectorEventArgs
{
RoutedEvent = DragDeltaEvent,
@ -100,7 +100,7 @@ namespace Avalonia.Controls.Primitives
protected override void OnPointerPressed(PointerPressedEventArgs e)
{
e.Handled = true;
_lastPoint = e.GetPosition(this.GetVisualParent());
_lastPoint = e.GetPosition(null);
var ev = new VectorEventArgs
{
@ -123,7 +123,7 @@ namespace Avalonia.Controls.Primitives
var ev = new VectorEventArgs
{
RoutedEvent = DragCompletedEvent,
Vector = (Vector)e.GetPosition(this.GetVisualParent()),
Vector = (Vector)e.GetPosition(null),
};
RaiseEvent(ev);

Loading…
Cancel
Save