Skip to content

Commit 4f6cbac

Browse files
Change behavior to allow chaining
1 parent 92c4b0d commit 4f6cbac

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

manim/mobject/builders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,6 @@ def add_updater(*method_args, **method_kwargs):
9999
lambda m: getattr(m, name)(*method_args, **method_kwargs),
100100
call_updater=True,
101101
)
102-
return mob
102+
return self
103103

104104
return add_updater

manim/mobject/mobject.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,9 @@ def construct(self):
395395
def always(self) -> Self:
396396
"""Call a method on a mobject every frame.
397397
398-
This is syntactic sugar for ``mob.add_updater(lambda m: m.method())``
398+
This is syntactic sugar for ``mob.add_updater(lambda m: m.method(*args, **kwargs), call_updater=True)``.
399+
Note that this will call the method immediately. If this behavior is not
400+
desired, you should use :meth:`add_updater` directly.
399401
400402
.. warning::
401403
@@ -413,12 +415,13 @@ def always(self) -> Self:
413415
class AlwaysExample(Scene):
414416
def construct(self):
415417
sq = Square().to_edge(LEFT)
416-
t = Text("Hello World!").always.next_to(sq, UP)
418+
t = Text("Hello World!")
419+
t.always.next_to(sq, UP)
417420
self.add(sq, t)
418421
self.play(sq.animate.to_edge(RIGHT))
419422
420423
"""
421-
# can't use typing.cast because Self is under typing_extensions
424+
# can't use typing.cast because Self is under TYPE_CHECKING
422425
return _UpdaterBuilder(self) # type: ignore
423426

424427
def __deepcopy__(self, clone_from_id) -> Self:

0 commit comments

Comments
 (0)