-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Trim shape default type value #2478
Conversation
@@ -34,7 +34,7 @@ final class Trim: ShapeItem { | |||
end = try KeyframeGroup<LottieVector1D>(dictionary: endDictionary) | |||
let offsetDictionary: [String: Any] = try dictionary.value(for: CodingKeys.offset) | |||
offset = try KeyframeGroup<LottieVector1D>(dictionary: offsetDictionary) | |||
let trimTypeRawValue: Int = try dictionary.value(for: CodingKeys.trimType) | |||
let trimTypeRawValue: Int = try dictionary.value(for: CodingKeys.trimType) ?? TrimType.individually.rawValue |
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.
Please also make this change in the Decodable
init above
Thanks! Could you add a sample json animation using this functionality as |
@calda I've updated the decoder method and added a test sample. I'm not sure why some of the tests have failed. Seems unrelated to this change. |
You have to record snapshots for the new sample animation, that's why the tests are failing :) |
I pushed a change that adds the snapshots. |
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.
Thanks!
I created a .lottie animation using a third party tool and I tried to render it using lottie-ios. Unfortunately, it logged an error and didn't display the file.
However, my animation was rendering just fine in the browser. After some digging, it turns out that the the trim shape dictionary decoder requires it to have a type specified. The JavaScript implementation (and probably others) doesn't require it and sets default value when not found:
https://github.com/LottieFiles/lottie-js/blob/a1bc6c5668323161a08159a2e040ff0cf14ab46c/src/shapes/trim-shape.ts#L40
In this PR, I set default trim type to
individual
. Similar to the JavaScript implementation.