Skip to content

Commit dcc6a58

Browse files
authored
Move code using node before its introduction in animations.md (#1442)
While node is added in section 6, the code in section 4 passes `node` in `clone()`. IMO, the code in section 4 should not pass the `node`. I’ve added more code in section 6 to make the explanation clearer.
1 parent 3a29062 commit dcc6a58

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

book/animations.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,7 @@ to the visual effects classes. For `Blend`, it'll create a new
662662
class Blend(VisualEffect):
663663
# ...
664664
def clone(self, child):
665-
return Blend(self.opacity, self.blend_mode,
666-
self.node, [child])
665+
return Blend(self.opacity, self.blend_mode, [child])
667666
```
668667

669668
Our browser won't be cloning paint commands, since they're all going to be
@@ -1321,6 +1320,15 @@ class VisualEffect:
13211320
def __init__(self, rect, children, node=None):
13221321
# ...
13231322
self.node = node
1323+
1324+
class Blend(VisualEffect):
1325+
def __init__(self, opacity, blend_mode, node, children):
1326+
super().__init__(skia.Rect.MakeEmpty(), children, node)
1327+
# ...
1328+
1329+
def clone(self, child):
1330+
return Blend(self.opacity, self.blend_mode,
1331+
self.node, [child])
13241332
```
13251333

13261334
Now, when an animation runs---but nothing else changes---we'll use

0 commit comments

Comments
 (0)