@@ -42,8 +42,9 @@ class WidgetAnimator:
4242 @staticmethod
4343 def show_widget (widget , anim_type = "fade" , duration = 500 , delay = 0 ):
4444 """Show a widget with an animation (fade or slide)."""
45- # Clear HIDDEN flag to make widget visible for animation
46- widget .remove_flag (lv .obj .FLAG .HIDDEN )
45+
46+ lv .anim_delete (widget , None ) # stop all ongoing animations to prevent visual glitches
47+ widget .remove_flag (lv .obj .FLAG .HIDDEN ) # Clear HIDDEN flag to make widget visible for animation
4748
4849 if anim_type == "fade" :
4950 # Create fade-in animation (opacity from 0 to 255)
@@ -91,9 +92,12 @@ def show_widget(widget, anim_type="fade", duration=500, delay=0):
9192 # Store and start animation
9293 #self.animations[widget] = anim
9394 anim .start ()
95+ return anim
9496
9597 @staticmethod
9698 def hide_widget (widget , anim_type = "fade" , duration = 500 , delay = 0 , hide = True ):
99+ lv .anim_delete (widget , None ) # stop all ongoing animations to prevent visual glitches
100+
97101 """Hide a widget with an animation (fade or slide)."""
98102 if anim_type == "fade" :
99103 # Create fade-out animation (opacity from 255 to 0)
@@ -141,6 +145,7 @@ def hide_widget(widget, anim_type="fade", duration=500, delay=0, hide=True):
141145 # Store and start animation
142146 #self.animations[widget] = anim
143147 anim .start ()
148+ return anim
144149
145150 @staticmethod
146151 def hide_complete_cb (widget , original_y = None , hide = True ):
@@ -152,7 +157,7 @@ def hide_complete_cb(widget, original_y=None, hide=True):
152157
153158
154159def smooth_show (widget ):
155- WidgetAnimator .show_widget (widget , anim_type = "fade" , duration = 500 , delay = 0 )
160+ return WidgetAnimator .show_widget (widget , anim_type = "fade" , duration = 500 , delay = 0 )
156161
157162def smooth_hide (widget , hide = True ):
158- WidgetAnimator .hide_widget (widget , anim_type = "fade" , duration = 500 , delay = 0 , hide = hide )
163+ return WidgetAnimator .hide_widget (widget , anim_type = "fade" , duration = 500 , delay = 0 , hide = hide )
0 commit comments