def construct(self): dot = Dot() text = TextMobject("Label") \ .next_to(dot, RIGHT, buff=SMALL_BUFF) self.add(dot, text) # Add update function to the objects text.add_updater(lambda m: m.next_to(dot, RIGHT, buff=SMALL_BUFF)) # Add the object again self.add(text) self.play(dot.shift, UP * 2) # Remove update function text.clear_updaters() self.wait()
def construct(self): dot = Dot() text = TextMobject("Label") \ .next_to(dot, RIGHT, buff=SMALL_BUFF) self.add(dot, text) # Update function def update_text(obj): obj.next_to(dot, RIGHT, buff=SMALL_BUFF) # Add update function to the objects text.add_updater(update_text) # Add the object again self.add(text) self.play(dot.shift, UP * 2) # Remove update function text.remove_updater(update_text) self.wait()