Skip to content

Commit 46dbf3d

Browse files
Laifsynpre-commit-ci[bot]chopan050JasonGrace2282
authored
Call .finish() for every animation in AnimationGroup on finish (#3951)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Francisco Manríquez Novoa <[email protected]> Co-authored-by: JasonGrace2282 <[email protected]> Co-authored-by: Aarush Deshpande <[email protected]>
1 parent 6abcc61 commit 46dbf3d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

manim/animation/composition.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ def _setup_scene(self, scene) -> None:
9898
anim._setup_scene(scene)
9999

100100
def finish(self) -> None:
101-
self.interpolate(1)
101+
for anim in self.animations:
102+
anim.finish()
102103
self.anims_begun[:] = True
103104
self.anims_finished[:] = True
104105
if self.suspend_mobject_updating:

tests/module/animation/test_composition.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,24 @@ def test_animationgroup_is_passing_remover_to_nested_animationgroups():
171171
assert polygon_animation.remover
172172

173173

174+
def test_animationgroup_calls_finish():
175+
class MyAnimation(Animation):
176+
def __init__(self, mobject):
177+
super().__init__(mobject)
178+
self.finished = False
179+
180+
def finish(self):
181+
self.finished = True
182+
183+
scene = Scene()
184+
sqr_animation = MyAnimation(Square())
185+
circ_animation = MyAnimation(Circle())
186+
animation_group = AnimationGroup(sqr_animation, circ_animation)
187+
scene.play(animation_group)
188+
assert sqr_animation.finished
189+
assert circ_animation.finished
190+
191+
174192
def test_empty_animation_group_fails():
175193
with pytest.raises(ValueError, match="Please add at least one subanimation."):
176194
AnimationGroup().begin()

0 commit comments

Comments
 (0)