Skip to content

Commit

Permalink
Change behavior to allow chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Jul 13, 2024
1 parent 92c4b0d commit 4f6cbac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manim/mobject/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ def add_updater(*method_args, **method_kwargs):
lambda m: getattr(m, name)(*method_args, **method_kwargs),
call_updater=True,
)
return mob
return self

return add_updater
9 changes: 6 additions & 3 deletions manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ def construct(self):
def always(self) -> Self:
"""Call a method on a mobject every frame.
This is syntactic sugar for ``mob.add_updater(lambda m: m.method())``
This is syntactic sugar for ``mob.add_updater(lambda m: m.method(*args, **kwargs), call_updater=True)``.
Note that this will call the method immediately. If this behavior is not
desired, you should use :meth:`add_updater` directly.
.. warning::
Expand All @@ -413,12 +415,13 @@ def always(self) -> Self:
class AlwaysExample(Scene):
def construct(self):
sq = Square().to_edge(LEFT)
t = Text("Hello World!").always.next_to(sq, UP)
t = Text("Hello World!")
t.always.next_to(sq, UP)
self.add(sq, t)
self.play(sq.animate.to_edge(RIGHT))
"""
# can't use typing.cast because Self is under typing_extensions
# can't use typing.cast because Self is under TYPE_CHECKING
return _UpdaterBuilder(self) # type: ignore

def __deepcopy__(self, clone_from_id) -> Self:
Expand Down

0 comments on commit 4f6cbac

Please sign in to comment.