airbnb / lottie-ios

An iOS library to natively render After Effects vector animations
http://airbnb.io/lottie/
Apache License 2.0
25.7k stars 3.74k forks source link

Add more accessors to `CompatibleAnimation` #2446

Closed Lancelotbronner closed 2 months ago

Lancelotbronner commented 2 months ago

Which Version of Lottie are you using?

Lottie 4.4.3

Expected Behavior

I need to access animation properties, like width and height, from a CompatibleAnimationView. I also load it from data so CompatibleAnimation is always nil.

I need a way to access these properties, the more logical place would be CompatibleAnimation but that would require refactoring.

Actual Behavior

These properties are unreachable, CompatibleAnimationView has a frame of zero after initialization. I don't have any way of knowing the size of my animation and our legacy engine needs it.

Animation JSON

N/A

Lancelotbronner commented 2 months ago

My suggestion on Sources/Public/iOS/Compatibility/CompatibleAnimationView, add the following:

@objc var animationWidth: CGFloat { animation?.width ?? 0 }
@objc var animationHeight: CGFloat { animation?.height ?? 0 }