-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add possibility to remove ValueProvider #2474
Changes from all commits
e33fdb5
fed12ef
fcd4fca
b55cedb
2e4503c
7cee759
cd0f3db
03c9113
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,6 +241,17 @@ final class MainThreadAnimationLayer: CALayer, RootAnimationLayer { | |
} | ||
} | ||
|
||
func removeValueProvider(for keypath: AnimationKeypath) { | ||
for layer in animationLayers { | ||
if let foundProperties = layer.nodeProperties(for: keypath) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like I mentioned in #2474 (comment), I think this behavior is different than the behavior implemented for the Core Animation rendering engine in
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have a strong preference on which approach is better (removing all matches, or just removing exact matches) but I think the behavior of the Core Animation engine and Main Thread engine needs to be the same. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a feeling updating the behavior of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, @calda, for your assistance! |
||
for property in foundProperties { | ||
property.removeProvider() | ||
} | ||
layer.displayWithFrame(frame: presentation()?.currentFrame ?? currentFrame, forceUpdates: true) | ||
} | ||
} | ||
} | ||
|
||
func getValue(for keypath: AnimationKeypath, atFrame: CGFloat?) -> Any? { | ||
for layer in animationLayers { | ||
if | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,5 +76,24 @@ final class ValueProvidersTests: XCTestCase { | |
for: "Layer.Shape Group.Stroke 1.Color", | ||
context: animationContext) | ||
XCTAssertEqual(keyFramesQuery4?.keyframes.map(\.value.components), [[0, 0, 0, 1]]) | ||
|
||
// Test removing specific keypath | ||
let keypathToRemove: AnimationKeypath = "**.Color" | ||
store.setValueProvider(ColorValueProvider(.black), keypath: keypathToRemove) | ||
store.removeValueProvider(for: keypathToRemove) | ||
let keyFramesQuery5 = try store.customKeyframes( | ||
of: .color, | ||
for: "Layer.Shape Group.Stroke 1.Color", | ||
context: animationContext) | ||
XCTAssertNil(keyFramesQuery5) | ||
|
||
// Test removing wildcard keypath | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
store.setValueProvider(ColorValueProvider(.black), keypath: "**1.Color") | ||
store.removeValueProvider(for: "**.Color") | ||
let keyFramesQuery6 = try store.customKeyframes( | ||
of: .color, | ||
for: "Layer.Shape Group.Stroke 1.Color", | ||
context: animationContext) | ||
XCTAssertNil(keyFramesQuery6) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect