Skip to content

Call .finish() for every animation in AnimationGroup on finish #3951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading