Skip to content

Commit

Permalink
Respect LayerModel.hidden and ShapeItem.hidden flags (#1689)
Browse files Browse the repository at this point in the history
  • Loading branch information
calda authored Aug 2, 2022
1 parent df2eda5 commit d5b3027
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ extension LayerModel {
func makeAnimationLayer(context: LayerContext) throws -> BaseCompositionLayer? {
let context = context.forLayer(self)

if hidden {
return TransformLayer(layerModel: self)
}

switch (type, self) {
case (.precomp, let preCompLayerModel as PreCompLayerModel):
let preCompLayer = PreCompLayer(preCompLayer: preCompLayerModel)
Expand Down
11 changes: 7 additions & 4 deletions Sources/Private/CoreAnimation/Layers/ShapeLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ final class GroupLayer: BaseAnimationLayer {
private let inheritedItems: [ShapeItemLayer.Item]

/// `ShapeItem`s (other than nested `Group`s) that are included in this group
private lazy var nonGroupItems = group.items
.filter { !($0 is Group) }
.map { ShapeItemLayer.Item(item: $0, parentGroup: group) }
+ inheritedItems
private lazy var nonGroupItems = (
group.items
.filter { !($0 is Group) }
.map { ShapeItemLayer.Item(item: $0, parentGroup: group) }
+ inheritedItems)
.filter { !$0.item.hidden }

private func setupLayerHierarchy(context: LayerContext) throws {
// Groups can contain other groups, so we may have to continue
Expand Down Expand Up @@ -207,6 +209,7 @@ extension CALayer {
// Groups are listed from front to back,
// but `CALayer.sublayers` are listed from back to front.
let groupsInZAxisOrder = groupItems.reversed()
.filter { !$0.hidden }

return try groupsInZAxisOrder.compactMap { group in
guard let group = group as? Group else { return nil }
Expand Down
1 change: 1 addition & 0 deletions Tests/Samples/Issues/issue_1687.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"5.7.6","fr":29.9700012207031,"ip":0,"op":100,"w":225,"h":225,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[112.5,112.5,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[111,111],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":0,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":true},{"ty":"fl","c":{"a":0,"k":[0.98431372549,0.737254901961,0.01568627451,1],"ix":4},"o":{"a":0,"ix":5,"k":[{"s":0,"t":0,"i":null,"o":null,"ti":null,"to":null,"h":1},{"s":100,"t":50,"i":null,"o":null,"ti":null,"to":null,"h":0},{"s":0,"t":100,"i":null,"o":null,"ti":null,"to":null,"h":0}]},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":true},{"ty":"tr","p":{"a":0,"k":[-3,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":true}],"ip":0,"op":900.000036657751,"st":0,"bm":0}],"markers":[]}

0 comments on commit d5b3027

Please sign in to comment.