Browse Source

feat: resolve dragging position flickering issue.

pull/11618/head
rabbitism 3 years ago
parent
commit
beb7cec6c4
  1. 7
      src/Avalonia.Controls/ToggleSwitch.cs

7
src/Avalonia.Controls/ToggleSwitch.cs

@ -230,7 +230,7 @@ namespace Avalonia.Controls
_knobsPanel!.ClearValue(Canvas.LeftProperty); _knobsPanel!.ClearValue(Canvas.LeftProperty);
PseudoClasses.Set(":dragging", false); PseudoClasses.Set(":dragging", false);
if (shouldBecomeChecked == IsChecked) if (shouldBecomeChecked == IsChecked)
{ {
UpdateKnobPos(shouldBecomeChecked); UpdateKnobPos(shouldBecomeChecked);
@ -239,6 +239,7 @@ namespace Avalonia.Controls
{ {
SetCurrentValue(IsCheckedProperty, shouldBecomeChecked); SetCurrentValue(IsCheckedProperty, shouldBecomeChecked);
} }
UpdateKnobTransitions();
} }
else else
{ {
@ -254,6 +255,10 @@ namespace Avalonia.Controls
{ {
if (_knobsPanelPressed) if (_knobsPanelPressed)
{ {
if(_knobsPanel != null)
{
_knobsPanel.Transitions = null;
}
var difference = e.GetPosition(_switchKnob) - _switchStartPoint; var difference = e.GetPosition(_switchKnob) - _switchStartPoint;
if ((!_isDragging) && (System.Math.Abs(difference.X) > 3)) if ((!_isDragging) && (System.Math.Abs(difference.X) > 3))

Loading…
Cancel
Save