From 7aa88e2dc69ccc0d9c4cfb2c9fc10a27c73fba36 Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Thu, 14 Jan 2021 11:44:17 +0100 Subject: [PATCH] Fixed bug in slider when maximum equal to or less than the minimum was supplied. --- ui/slider.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/slider.go b/ui/slider.go index 1c9c66f..f180a68 100644 --- a/ui/slider.go +++ b/ui/slider.go @@ -90,7 +90,10 @@ func (s *Slider) Arrange(ctx Context, bounds geom.RectangleF32, offset geom.Poin start, length, center := s.offsets() w := s.handleWidth w05 := .5 * w - handleOffset := (s.Value - s.Minimum) / (s.Maximum - s.Minimum) + var handleOffset float32 + if s.Maximum > s.Minimum { + handleOffset = (s.Value - s.Minimum) / (s.Maximum - s.Minimum) + } if !geom.IsNaN32(handleOffset) { start += handleOffset * length }