From 95baa789ef2584dd98f8b710b4a9f6949e25319b Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Sun, 23 Nov 2025 14:47:28 +0100 Subject: [PATCH] mpos.ui.anim: stop ongoing animation when starting new This prevents visual glitches when both animations are ongoing. --- internal_filesystem/lib/mpos/ui/anim.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/internal_filesystem/lib/mpos/ui/anim.py b/internal_filesystem/lib/mpos/ui/anim.py index 521ee9ac..0ae5068a 100644 --- a/internal_filesystem/lib/mpos/ui/anim.py +++ b/internal_filesystem/lib/mpos/ui/anim.py @@ -42,8 +42,9 @@ class WidgetAnimator: @staticmethod def show_widget(widget, anim_type="fade", duration=500, delay=0): """Show a widget with an animation (fade or slide).""" - # Clear HIDDEN flag to make widget visible for animation - widget.remove_flag(lv.obj.FLAG.HIDDEN) + + lv.anim_delete(widget, None) # stop all ongoing animations to prevent visual glitches + widget.remove_flag(lv.obj.FLAG.HIDDEN) # Clear HIDDEN flag to make widget visible for animation if anim_type == "fade": # Create fade-in animation (opacity from 0 to 255) @@ -91,9 +92,12 @@ class WidgetAnimator: # Store and start animation #self.animations[widget] = anim anim.start() + return anim @staticmethod def hide_widget(widget, anim_type="fade", duration=500, delay=0, hide=True): + lv.anim_delete(widget, None) # stop all ongoing animations to prevent visual glitches + """Hide a widget with an animation (fade or slide).""" if anim_type == "fade": # Create fade-out animation (opacity from 255 to 0) @@ -141,6 +145,7 @@ class WidgetAnimator: # Store and start animation #self.animations[widget] = anim anim.start() + return anim @staticmethod def hide_complete_cb(widget, original_y=None, hide=True): @@ -152,7 +157,7 @@ class WidgetAnimator: def smooth_show(widget): - WidgetAnimator.show_widget(widget, anim_type="fade", duration=500, delay=0) + return WidgetAnimator.show_widget(widget, anim_type="fade", duration=500, delay=0) def smooth_hide(widget, hide=True): - WidgetAnimator.hide_widget(widget, anim_type="fade", duration=500, delay=0, hide=hide) + return WidgetAnimator.hide_widget(widget, anim_type="fade", duration=500, delay=0, hide=hide)