Skip to content

Commit

Permalink
set negatives to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
ericleonardis committed Jan 2, 2025
1 parent fb35ff2 commit ad57162
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sleap/gui/widgets/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ def _toVal(self, x: float, center=False) -> float:
Returns:
Slider value (frame index).
"""
if x is None:
raise ValueError("x position cannot be None")

val = x
val /= self._slider_width
val *= max(1, self._val_max - self._val_min)
Expand All @@ -389,7 +392,10 @@ def _toVal(self, x: float, center=False) -> float:
@property
def _slider_width(self) -> float:
"""Returns visual width of slider."""
return self.box_rect.width()
width = self.box_rect.width()
if width <= 0:
return 1.0
return width

@property
def slider_visible_value_range(self) -> float:
Expand Down

0 comments on commit ad57162

Please sign in to comment.