Skip to content

Commit

Permalink
Enable time remapping
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon_withrow committed Jan 3, 2018
1 parent 650a82e commit 6434ec1
Show file tree
Hide file tree
Showing 27 changed files with 1,068 additions and 981 deletions.
1,848 changes: 930 additions & 918 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Example/Tests/timeremap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"4.12.0","fr":23.9759979248047,"ip":0,"op":48.9999957589018,"w":300,"h":300,"nm":"TimeRemap","ddd":0,"assets":[{"id":"comp_1","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0],"e":[360]},{"t":47.9999958454548}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":0,"s":[150,60,0],"e":[150,225,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":13,"s":[150,225,0],"e":[150,60,0],"to":[0,0,0],"ti":[0,0,0]},{"t":47.9999958454548}],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[109.172,109.172],"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":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.431255026425,0,0.902665022308,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0.32,4.668],"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,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":48.9999957589018,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"Freeze","refId":"comp_1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[146,220,0],"ix":2},"a":{"a":0,"k":[150,150,0],"ix":1},"s":{"a":0,"k":[50.667,50.667,100],"ix":6}},"ao":0,"tm":{"a":0,"k":0.876,"ix":2},"w":300,"h":300,"ip":0,"op":48.9999957589018,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":0,"nm":"Reverse","refId":"comp_1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[247,220,0],"ix":2},"a":{"a":0,"k":[150,150,0],"ix":1},"s":{"a":0,"k":[50.667,50.667,100],"ix":6}},"ao":0,"tm":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[2.044],"e":[0]},{"t":48.9999957589018}],"ix":2},"w":300,"h":300,"ip":0,"op":48.9999957589018,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":0,"nm":"Regular","refId":"comp_1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[43,220,0],"ix":2},"a":{"a":0,"k":[150,150,0],"ix":1},"s":{"a":0,"k":[50.667,50.667,100],"ix":6}},"ao":0,"w":300,"h":300,"ip":0,"op":48.9999957589018,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":0,"nm":"Stretch","refId":"comp_1","sr":0.2,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[44,71,0],"ix":2},"a":{"a":0,"k":[150,150,0],"ix":1},"s":{"a":0,"k":[50.667,50.667,100],"ix":6}},"ao":0,"w":300,"h":300,"ip":0,"op":9.79999915178036,"st":0,"bm":0}]}
4 changes: 4 additions & 0 deletions Example/lottie-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
622F77091F2BE63100269858 /* X.json in Resources */ = {isa = PBXBuildFile; fileRef = 622F76EB1F2BE63100269858 /* X.json */; };
622F770A1F2BE63100269858 /* Y.json in Resources */ = {isa = PBXBuildFile; fileRef = 622F76EC1F2BE63100269858 /* Y.json */; };
622F770B1F2BE63100269858 /* Z.json in Resources */ = {isa = PBXBuildFile; fileRef = 622F76ED1F2BE63100269858 /* Z.json */; };
6257F31E1FFD65BC00DAE7B2 /* timeremap.json in Resources */ = {isa = PBXBuildFile; fileRef = 6257F31D1FFD65BB00DAE7B2 /* timeremap.json */; };
6289F3851FE4A3F500C10B3E /* setValueTest.json in Resources */ = {isa = PBXBuildFile; fileRef = 6289F3841FE4A3F500C10B3E /* setValueTest.json */; };
6289F3871FE877FC00C10B3E /* GeometryTransformTest.json in Resources */ = {isa = PBXBuildFile; fileRef = 6289F3861FE877FC00C10B3E /* GeometryTransformTest.json */; };
6289F3881FE877FC00C10B3E /* GeometryTransformTest.json in Resources */ = {isa = PBXBuildFile; fileRef = 6289F3861FE877FC00C10B3E /* GeometryTransformTest.json */; };
Expand Down Expand Up @@ -176,6 +177,7 @@
622F76EC1F2BE63100269858 /* Y.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Y.json; sourceTree = "<group>"; };
622F76ED1F2BE63100269858 /* Z.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Z.json; sourceTree = "<group>"; };
62569CB2461B12ABC97FCB96 /* lottie-ios.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = "lottie-ios.podspec"; path = "../lottie-ios.podspec"; sourceTree = "<group>"; };
6257F31D1FFD65BB00DAE7B2 /* timeremap.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = timeremap.json; sourceTree = "<group>"; };
6289F3841FE4A3F500C10B3E /* setValueTest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = setValueTest.json; sourceTree = "<group>"; };
6289F3861FE877FC00C10B3E /* GeometryTransformTest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = GeometryTransformTest.json; sourceTree = "<group>"; };
6289F3891FE8784200C10B3E /* LAGeometryTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LAGeometryTest.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -373,6 +375,7 @@
622F76B91F2BE58100269858 /* LottieLogo1.json */,
622F76BB1F2BE58100269858 /* MotionCorpse-Jrcanest.json */,
622F76BC1F2BE58100269858 /* PinJump.json */,
6257F31D1FFD65BB00DAE7B2 /* timeremap.json */,
622F76BD1F2BE58100269858 /* TwitterHeart.json */,
622F76BF1F2BE58100269858 /* vcTransition1.json */,
622F76C01F2BE58100269858 /* vcTransition2.json */,
Expand Down Expand Up @@ -628,6 +631,7 @@
622F77021F2BE63100269858 /* Q.json in Resources */,
629EC5811F54C00B005B2C59 /* Switch.json in Resources */,
622F76FB1F2BE63100269858 /* J.json in Resources */,
6257F31E1FFD65BC00DAE7B2 /* timeremap.json in Resources */,
622F77081F2BE63100269858 /* W.json in Resources */,
622F76F61F2BE63100269858 /* E.json in Resources */,
622F76C41F2BE58100269858 /* IconTransitions.json in Resources */,
Expand Down
14 changes: 13 additions & 1 deletion Lottie.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@
62CA59AF1E3C173B002D7188 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0830;
LastUpgradeCheck = 0910;
ORGANIZATIONNAME = Airbnb;
TargetAttributes = {
62CA59B71E3C173B002D7188 = {
Expand Down Expand Up @@ -1187,15 +1187,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -1240,15 +1246,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down
4 changes: 3 additions & 1 deletion Lottie.xcodeproj/xcshareddata/xcschemes/Lottie.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file added _AeFiles/TimeRemap.aep
Binary file not shown.
14 changes: 12 additions & 2 deletions lottie-ios/Classes/AnimatableLayers/LOTCompositionContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
#import "LOTAnimatorNode.h"
#import "LOTRenderNode.h"
#import "LOTRenderGroup.h"
#import "LOTNumberInterpolator.h"

@implementation LOTCompositionContainer {
NSNumber *_frameOffset;
CALayer *DEBUG_Center;
NSMutableDictionary *_keypathCache;
LOTNumberInterpolator *_timeInterpolator;
}

- (instancetype)initWithModel:(LOTLayer *)layer
Expand All @@ -41,6 +43,11 @@ - (instancetype)initWithModel:(LOTLayer *)layer
} else {
_frameOffset = @0;
}

if (layer.timeRemapping) {
_timeInterpolator = [[LOTNumberInterpolator alloc] initWithKeyframes:layer.timeRemapping.keyframes];
}

[self initializeWithChildGroup:childLayerGroup withAssetGroup:assetGroup];
}
return self;
Expand Down Expand Up @@ -89,9 +96,12 @@ - (void)initializeWithChildGroup:(LOTLayerGroup *)childGroup
- (void)displayWithFrame:(NSNumber *)frame forceUpdate:(BOOL)forceUpdate {
if (ENABLE_DEBUG_LOGGING) NSLog(@"-------------------- Composition Displaying Frame %@ --------------------", frame);
[super displayWithFrame:frame forceUpdate:forceUpdate];
NSNumber *childFrame = @(frame.floatValue - _frameOffset.floatValue);
NSNumber *newFrame = @((frame.floatValue - _frameOffset.floatValue) / self.timeStretchFactor.floatValue);
if (_timeInterpolator) {
newFrame = @([_timeInterpolator floatValueForFrame:newFrame]);
}
for (LOTLayerContainer *child in _childLayers) {
[child displayWithFrame:childFrame forceUpdate:forceUpdate];
[child displayWithFrame:newFrame forceUpdate:forceUpdate];
}
if (ENABLE_DEBUG_LOGGING) NSLog(@"-------------------- ------------------------------- --------------------");
if (ENABLE_DEBUG_LOGGING) NSLog(@"-------------------- ------------------------------- --------------------");
Expand Down
5 changes: 4 additions & 1 deletion lottie-ios/Classes/AnimatableLayers/LOTLayerContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#import "LOTLayer.h"
#import "LOTLayerGroup.h"
#import "LOTKeypath.h"
#import "LOTValueCallback.h"

@class LOTValueCallback;

@interface LOTLayerContainer : CALayer

Expand All @@ -19,9 +20,11 @@

@property (nonatomic, readonly, strong, nullable) NSString *layerName;
@property (nonatomic, nullable) NSNumber *currentFrame;
@property (nonatomic, readonly, nonnull) NSNumber *timeStretchFactor;
@property (nonatomic, assign) CGRect viewportBounds;
@property (nonatomic, readonly, nonnull) CALayer *wrapperLayer;
@property (nonatomic, readonly, nonnull) NSDictionary *valueInterpolators;

- (void)displayWithFrame:(NSNumber * _Nonnull)frame;
- (void)displayWithFrame:(NSNumber * _Nonnull)frame forceUpdate:(BOOL)forceUpdate;

Expand Down
19 changes: 12 additions & 7 deletions lottie-ios/Classes/AnimatableLayers/LOTLayerContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ - (instancetype)initWithModel:(LOTLayer *)layer
}
self.actions = @{@"hidden" : [NSNull null], @"opacity" : [NSNull null], @"transform" : [NSNull null]};
_wrapperLayer.actions = [self.actions copy];
_timeStretchFactor = @1;
[self commonInitializeWith:layer inLayerGroup:layerGroup];
}
return self;
Expand All @@ -75,7 +76,10 @@ - (void)commonInitializeWith:(LOTLayer *)layer

_inFrame = [layer.inFrame copy];
_outFrame = [layer.outFrame copy];

_timeStretchFactor = [layer.timeStretch copy];
_transformInterpolator = [LOTTransformInterpolator transformForLayer:layer];

if (layer.parentID) {
NSNumber *parentID = layer.parentID;
LOTTransformInterpolator *childInterpolator = _transformInterpolator;
Expand Down Expand Up @@ -233,7 +237,8 @@ - (void)displayWithFrame:(NSNumber *)frame {
}

- (void)displayWithFrame:(NSNumber *)frame forceUpdate:(BOOL)forceUpdate {
if (ENABLE_DEBUG_LOGGING) NSLog(@"View %@ Displaying Frame %@", self, frame);
NSNumber *newFrame = @(frame.floatValue / self.timeStretchFactor.floatValue);
if (ENABLE_DEBUG_LOGGING) NSLog(@"View %@ Displaying Frame %@, with local time %@", self, frame, newFrame);
BOOL hidden = NO;
if (_inFrame && _outFrame) {
hidden = (frame.floatValue < _inFrame.floatValue ||
Expand All @@ -243,14 +248,14 @@ - (void)displayWithFrame:(NSNumber *)frame forceUpdate:(BOOL)forceUpdate {
if (hidden) {
return;
}
if (_opacityInterpolator && [_opacityInterpolator hasUpdateForFrame:frame]) {
self.opacity = [_opacityInterpolator floatValueForFrame:frame];
if (_opacityInterpolator && [_opacityInterpolator hasUpdateForFrame:newFrame]) {
self.opacity = [_opacityInterpolator floatValueForFrame:newFrame];
}
if (_transformInterpolator && [_transformInterpolator hasUpdateForFrame:frame]) {
_wrapperLayer.transform = [_transformInterpolator transformForFrame:frame];
if (_transformInterpolator && [_transformInterpolator hasUpdateForFrame:newFrame]) {
_wrapperLayer.transform = [_transformInterpolator transformForFrame:newFrame];
}
[_contentsGroup updateWithFrame:frame withModifierBlock:nil forceLocalUpdate:forceUpdate];
_maskLayer.currentFrame = frame;
[_contentsGroup updateWithFrame:newFrame withModifierBlock:nil forceLocalUpdate:forceUpdate];
_maskLayer.currentFrame = newFrame;
}

- (void)setViewportBounds:(CGRect)viewportBounds {
Expand Down
3 changes: 2 additions & 1 deletion lottie-ios/Classes/Models/LOTAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ NS_ASSUME_NONNULL_BEGIN

- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary
withAssetGroup:(LOTAssetGroup * _Nullable)assetGroup
withAssetBundle:(NSBundle *_Nonnull)bundle;
withAssetBundle:(NSBundle *_Nonnull)bundle
withFramerate:(NSNumber *)framerate;

@property (nonatomic, readonly, nullable) NSString *referenceID;
@property (nonatomic, readonly, nullable) NSNumber *assetWidth;
Expand Down
12 changes: 8 additions & 4 deletions lottie-ios/Classes/Models/LOTAsset.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ @implementation LOTAsset

- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary
withAssetGroup:(LOTAssetGroup * _Nullable)assetGroup
withAssetBundle:(NSBundle *_Nonnull)bundle {
withAssetBundle:(NSBundle *_Nonnull)bundle
withFramerate:(NSNumber *)framerate {
self = [super init];
if (self) {
_assetBundle = bundle;
[self _mapFromJSON:jsonDictionary
withAssetGroup:assetGroup];
withAssetGroup:assetGroup
withFramerate:framerate];
}
return self;
}

- (void)_mapFromJSON:(NSDictionary *)jsonDictionary
withAssetGroup:(LOTAssetGroup * _Nullable)assetGroup {
withAssetGroup:(LOTAssetGroup * _Nullable)assetGroup
withFramerate:(NSNumber *)framerate {
_referenceID = [jsonDictionary[@"id"] copy];

if (jsonDictionary[@"w"]) {
Expand All @@ -48,7 +51,8 @@ - (void)_mapFromJSON:(NSDictionary *)jsonDictionary
NSArray *layersJSON = jsonDictionary[@"layers"];
if (layersJSON) {
_layerGroup = [[LOTLayerGroup alloc] initWithLayerJSON:layersJSON
withAssetGroup:assetGroup];
withAssetGroup:assetGroup
withFramerate:framerate];
}
}

Expand Down
7 changes: 4 additions & 3 deletions lottie-ios/Classes/Models/LOTAssetGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
@property (nonatomic, readonly, nullable) NSBundle *assetBundle;

- (instancetype _Nonnull)initWithJSON:(NSArray * _Nonnull)jsonArray
withAssetBundle:(NSBundle *_Nullable)bundle;
withAssetBundle:(NSBundle *_Nullable)bundle
withFramerate:(NSNumber * _Nonnull)framerate;

- (void)buildAssetNamed:(NSString * _Nonnull)refID;
- (void)buildAssetNamed:(NSString * _Nonnull)refID withFramerate:(NSNumber * _Nonnull)framerate;

- (void)finalizeInitialization;
- (void)finalizeInitializationWithFramerate:(NSNumber * _Nonnull)framerate;

- (LOTAsset * _Nullable)assetModelForID:(NSString * _Nonnull)assetID;

Expand Down
13 changes: 8 additions & 5 deletions lottie-ios/Classes/Models/LOTAssetGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ @implementation LOTAssetGroup {
}

- (instancetype _Nonnull)initWithJSON:(NSArray * _Nonnull)jsonArray
withAssetBundle:(NSBundle *_Nullable)bundle {
withAssetBundle:(NSBundle * _Nullable)bundle
withFramerate:(NSNumber * _Nonnull)framerate {
self = [super init];
if (self) {
_assetBundle = bundle;
Expand All @@ -32,7 +33,8 @@ - (instancetype _Nonnull)initWithJSON:(NSArray * _Nonnull)jsonArray
return self;
}

- (void)buildAssetNamed:(NSString *)refID {
- (void)buildAssetNamed:(NSString *)refID
withFramerate:(NSNumber * _Nonnull)framerate {

if ([self assetModelForID:refID]) {
return;
Expand All @@ -42,14 +44,15 @@ - (void)buildAssetNamed:(NSString *)refID {
if (assetDictionary) {
LOTAsset *asset = [[LOTAsset alloc] initWithJSON:assetDictionary
withAssetGroup:self
withAssetBundle:_assetBundle];
withAssetBundle:_assetBundle
withFramerate:framerate];
_assetMap[refID] = asset;
}
}

- (void)finalizeInitialization {
- (void)finalizeInitializationWithFramerate:(NSNumber * _Nonnull)framerate {
for (NSString *refID in _assetJSONMap.allKeys) {
[self buildAssetNamed:refID];
[self buildAssetNamed:refID withFramerate:framerate];
}
_assetJSONMap = nil;
}
Expand Down
5 changes: 4 additions & 1 deletion lottie-ios/Classes/Models/LOTLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface LOTLayer : NSObject

- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary
withAssetGroup:(LOTAssetGroup * _Nullable)assetGroup;
withAssetGroup:(LOTAssetGroup * _Nullable)assetGroup
withFramerate:(NSNumber *)framerate;

@property (nonatomic, readonly) NSString *layerName;
@property (nonatomic, readonly, nullable) NSString *referenceID;
Expand All @@ -46,6 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) NSNumber *startFrame;
@property (nonatomic, readonly) NSNumber *inFrame;
@property (nonatomic, readonly) NSNumber *outFrame;
@property (nonatomic, readonly) NSNumber *timeStretch;
@property (nonatomic, readonly) CGRect layerBounds;

@property (nonatomic, readonly, nullable) NSArray<LOTShapeGroup *> *shapes;
Expand All @@ -57,6 +59,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly, nullable) LOTAsset *imageAsset;

@property (nonatomic, readonly) LOTKeyframeGroup *opacity;
@property (nonatomic, readonly, nullable) LOTKeyframeGroup *timeRemapping;
@property (nonatomic, readonly) LOTKeyframeGroup *rotation;
@property (nonatomic, readonly, nullable) LOTKeyframeGroup *position;

Expand Down
Loading

0 comments on commit 6434ec1

Please sign in to comment.