Skip to content

Commit

Permalink
Call .finish() for every animation in AnimationGroup on finish (#…
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
5 people authored Dec 16, 2024
1 parent 6abcc61 commit 46dbf3d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion manim/animation/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def _setup_scene(self, scene) -> None:
anim._setup_scene(scene)

def finish(self) -> None:
self.interpolate(1)
for anim in self.animations:
anim.finish()
self.anims_begun[:] = True
self.anims_finished[:] = True
if self.suspend_mobject_updating:
Expand Down
18 changes: 18 additions & 0 deletions tests/module/animation/test_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,24 @@ def test_animationgroup_is_passing_remover_to_nested_animationgroups():
assert polygon_animation.remover


def test_animationgroup_calls_finish():
class MyAnimation(Animation):
def __init__(self, mobject):
super().__init__(mobject)
self.finished = False

def finish(self):
self.finished = True

scene = Scene()
sqr_animation = MyAnimation(Square())
circ_animation = MyAnimation(Circle())
animation_group = AnimationGroup(sqr_animation, circ_animation)
scene.play(animation_group)
assert sqr_animation.finished
assert circ_animation.finished


def test_empty_animation_group_fails():
with pytest.raises(ValueError, match="Please add at least one subanimation."):
AnimationGroup().begin()
Expand Down

0 comments on commit 46dbf3d

Please sign in to comment.