Skip to content

Commit 784b286

Browse files
authored
[LottieGen] Graph compactor fix. Do not coalesce root container visuals. (#467)
1 parent 7ae8a39 commit 784b286

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

source/UIData/Tools/GraphCompactor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,12 +1143,16 @@ where parent is not null && n.Node.AllowCoalesing
11431143
// affects different sets of properties then they can be combined into one.
11441144
void CoalesceOrthogonalContainerVisuals(ObjectGraph<Node> graph)
11451145
{
1146-
// If a container is not animated and has no properties set, its children can be inserted into its parent.
1146+
// If a container is not animated and has no properties set, its children can be inserted into its parent,
1147+
// except the root node. We should not change the root node since the user can try to change width/height/scale
1148+
// of the root node and in combination with non-null Clip property (or others)
1149+
// this can lead to incorrect animation.
11471150
var containersWithASingleContainer = graph.CompositionObjectNodes.Where(n =>
11481151
{
11491152
// Find the ContainerVisuals that have a single child that is a ContainerVisual.
11501153
return
11511154
n.Object is ContainerVisual container &&
1155+
n.Object != graph.Root.Object &&
11521156
container.Children.Count == 1 &&
11531157
container.Children[0].Type == CompositionObjectType.ContainerVisual;
11541158
}).ToArray();

0 commit comments

Comments
 (0)