diff --git a/core/decorators.py b/core/decorators.py index 56b2ead..307797d 100644 --- a/core/decorators.py +++ b/core/decorators.py @@ -41,21 +41,23 @@ def scrollable(func): direction = widget.get("scrolling.direction", "right") if direction == "left": - scroll_speed = -scroll_speed - if start + scroll_speed <= 0: # bounce back + if start - scroll_speed <= 0: # bounce back widget.set("scrolling.direction", "right") + else: + scroll_speed *= -1 + else: + if start + scroll_speed + width > len(text): + if not bounce: + start = -scroll_speed + else: + start = len(text) - width + scroll_speed *= -1 + widget.set("scrolling.direction", "left") next_start = start + scroll_speed - if next_start + width > len(text): - if not bounce: - next_start = 0 - else: - next_start = start - scroll_speed - widget.set("scrolling.direction", "left") - widget.set("scrolling.start", next_start) - return text[start : start + width] + return text[start:start + width] return wrapper