Skip to content

Commit 97b53c2

Browse files
committed
Avoid saving bullelist state at creation time
1 parent d2abc7d commit 97b53c2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/powermanim/components/vgrouphighlight.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ def __init__(
2929
"""
3030
super().__init__(*args, **kwargs)
3131

32-
for x in self.submobjects:
33-
x.save_state()
34-
3532
self.anim_run_time = anim_run_time
3633
self.anim_lag_ratio = anim_lag_ratio
3734
self.active_opacity = active_opacity
@@ -59,14 +56,17 @@ def highlight(self, indices: T.Union[int, T.Sequence[int]]) -> AnimationGroup:
5956
indices = [indices]
6057

6158
for to_highlight in indices:
62-
self.submobjects[to_highlight].target = self.submobjects[to_highlight].saved_state.copy()
63-
self.submobjects[to_highlight].target.scale(
59+
item = self.submobjects[to_highlight]
60+
if not hasattr(item, "saved_state") or item.saved_state is None:
61+
item.save_state()
62+
item.target = item.saved_state.copy()
63+
item.target.scale(
6464
self.scale_active,
6565
about_point=self.scale_about_point,
6666
about_edge=self.scale_about_edge,
6767
)
68-
self.submobjects[to_highlight].target.set_opacity(self.active_opacity)
69-
anims.append(MoveToTarget(self.submobjects[to_highlight]))
68+
item.target.set_opacity(self.active_opacity)
69+
anims.append(MoveToTarget(item))
7070

7171
if self.previously_active_idxs:
7272
for previously_active_idx in self.previously_active_idxs:

0 commit comments

Comments
 (0)