Browse Source

Make thumb drag delta relative to root.

#10892 changed the thumb drag delta to be relative to the parent, but the problem was that is that if the thumb controls the position of the parent then the delta will be incorrect.

This was causing a bug in `TreeDataGrid` headers which were jumping around: the `Thumb` is a child of the header and causes the header to move.
pull/11087/head
Steven Kirk 3 years ago
parent
commit
e5acebabcb
  1. 6
      src/Avalonia.Controls/Primitives/Thumb.cs

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((Visual?)this.GetVisualRoot());
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((Visual?)this.GetVisualRoot());
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((Visual?)this.GetVisualRoot()),
};
RaiseEvent(ev);

Loading…
Cancel
Save