Browse Source

Don't offset thumb from pointer when dragged past end.

pull/11252/head
Steven Kirk 3 years ago
parent
commit
c204156e8a
  1. 22
      src/Avalonia.Controls/Primitives/Track.cs

22
src/Avalonia.Controls/Primitives/Track.cs

@ -295,12 +295,6 @@ namespace Avalonia.Controls.Primitives
return arrangeSize;
}
private Vector CalculateThumbAdjustment(Thumb thumb, Rect newThumbBounds)
{
var thumbDelta = newThumbBounds.Position - thumb.Bounds.Position;
return _lastDrag - thumbDelta;
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
@ -311,6 +305,12 @@ namespace Avalonia.Controls.Primitives
}
}
private Vector CalculateThumbAdjustment(Thumb thumb, Rect newThumbBounds)
{
var thumbDelta = newThumbBounds.Position - thumb.Bounds.Position;
return _lastDrag - thumbDelta;
}
private static void CoerceLength(ref double componentLength, double trackLength)
{
if (componentLength < 0)
@ -455,11 +455,17 @@ namespace Avalonia.Controls.Primitives
if (IgnoreThumbDrag)
return;
var value = Value;
var delta = ValueFromDistance(e.Vector.X, e.Vector.Y);
var factor = e.Vector / delta;
SetCurrentValue(ValueProperty, MathUtilities.Clamp(
Value + ValueFromDistance(e.Vector.X, e.Vector.Y),
value + delta,
Minimum,
Maximum));
_lastDrag = e.Vector;
// Record the part of the drag that actually had effect as the last drag delta.
_lastDrag = (Value - value) * factor;
}
private void ShowChildren(bool visible)

Loading…
Cancel
Save