Browse Source

avoid divide by zero

pull/4051/head
Jumar Macato 6 years ago
parent
commit
66c677eab8
No known key found for this signature in database GPG Key ID: B19884DAC3A5BF3F
  1. 3
      src/Avalonia.Controls/Slider.cs

3
src/Avalonia.Controls/Slider.cs

@ -189,7 +189,10 @@ namespace Avalonia.Controls
private void MoveToPoint(PointerPoint x)
{
var orient = Orientation == Orientation.Horizontal;
var pointDen = orient ? _track.Bounds.Width : _track.Bounds.Height;
pointDen += double.Epsilon; // Just add epsilon to avoid divide by zero exceptions.
var pointNum = orient ? x.Position.X : x.Position.Y;
var logicalPos = MathUtilities.Clamp(pointNum / pointDen, 0.0d, 1.0d);
var invert = orient ? 0 : 1;

Loading…
Cancel
Save