Skip to content

Commit

Permalink
updated interactive api
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon_withrow committed Sep 1, 2017
1 parent bcc794e commit 3f004a0
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- lottie-ios (2.1.2)
- lottie-ios (2.1.3)

DEPENDENCIES:
- lottie-ios (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
lottie-ios: 0f66c4af9850da2a8193fc1a7fd089c59a01bb2e
lottie-ios: 8c150606598931621e927377f1426d2d3e99282d

PODFILE CHECKSUM: fdbd59f361db8744871f0e9a0b3f94e0b7b8ca6b

Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/lottie-ios.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lottie-ios/Classes/AnimatableLayers/LOTCompositionContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ - (BOOL)setValue:(nonnull id)value
childKey = [keypath stringByReplacingCharactersInRange:NSMakeRange(0, firstKey.length + 1) withString:@""];
}
}

BOOL childSet = NO;
if (childKey) {
for (LOTLayerContainer *child in _childLayers) {
BOOL childHasKey = [child setValue:value forKeypath:childKey atFrame:frame];
if (childHasKey) {
return childHasKey;
childSet = YES;
}
}
}
return NO;
return childSet;
}

- (void)addSublayer:(nonnull CALayer *)subLayer
Expand Down
29 changes: 28 additions & 1 deletion lottie-ios/Classes/AnimatableLayers/LOTLayerContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ - (void)commonInitializeWith:(LOTLayer *)layer
interpolators[@"Transform.Opacity"] = _opacityInterpolator;
interpolators[@"Transform.Anchor Point"] = _transformInterpolator.anchorInterpolator;
interpolators[@"Transform.Scale"] = _transformInterpolator.scaleInterpolator;
interpolators[@"Transform.Rotation"] = _transformInterpolator.scaleInterpolator;
interpolators[@"Transform.Rotation"] = _transformInterpolator.rotationInterpolator;
if (_transformInterpolator.positionXInterpolator &&
_transformInterpolator.positionYInterpolator) {
interpolators[@"Transform.X Position"] = _transformInterpolator.positionXInterpolator;
Expand Down Expand Up @@ -256,6 +256,33 @@ - (BOOL)setValue:(nonnull id)value
} else {
return [_contentsGroup setValue:value forKeyAtPath:keypath forFrame:frame];
}
} else {
NSArray *transFormComponents = [keypath componentsSeparatedByString:@".Transform."];
if (transFormComponents.count == 2) {
// Is a layer level transform. Check if it applies to a parent transform.
NSString *layerName = transFormComponents.firstObject;
NSString *attribute = transFormComponents.lastObject;
LOTTransformInterpolator *parentTransform = _transformInterpolator.inputNode;
while (parentTransform) {
if ([parentTransform.parentKeyName isEqualToString:layerName]) {
if ([attribute isEqualToString:@"Anchor Point"]) {
[parentTransform.anchorInterpolator setValue:value atFrame:frame];
} else if ([attribute isEqualToString:@"Scale"]) {
[parentTransform.scaleInterpolator setValue:value atFrame:frame];
} else if ([attribute isEqualToString:@"Rotation"]) {
[parentTransform.rotationInterpolator setValue:value atFrame:frame];
} else if ([attribute isEqualToString:@"X Position"]) {
[parentTransform.positionXInterpolator setValue:value atFrame:frame];
} else if ([attribute isEqualToString:@"Y Position"]) {
[parentTransform.positionYInterpolator setValue:value atFrame:frame];
} else if ([attribute isEqualToString:@"Position"]) {
[parentTransform.positionInterpolator setValue:value atFrame:frame];
}
parentTransform = nil;
}
parentTransform = parentTransform.inputNode;
}
}
}
return NO;
}
Expand Down
10 changes: 9 additions & 1 deletion lottie-ios/Classes/Extensions/LOTRadialGradientLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ + (BOOL)needsDisplayForKey:(NSString *)key {
return [super needsDisplayForKey:key];
}

- (id)actionForKey:(NSString *)key {
- (id)actionForKey:(NSString *)key {
id action = self.actions[key];
if (action) {
if (action == [NSNull null]) {
return nil;
}
return action;
}

if ([key isEqualToString:@"startPoint"] ||
[key isEqualToString:@"endPoint"] ||
[key isEqualToString:@"colors"] ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) LOTNumberInterpolator *rotationInterpolator;
@property (nonatomic, readonly) LOTNumberInterpolator *positionXInterpolator;
@property (nonatomic, readonly) LOTNumberInterpolator *positionYInterpolator;
@property (nonatomic, strong, nullable) NSString *parentKeyName;

- (CATransform3D)transformForFrame:(NSNumber *)frame;
- (BOOL)hasUpdateForFrame:(NSNumber *)frame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@ @implementation LOTTransformInterpolator {
}

+ (instancetype)transformForLayer:(LOTLayer *)layer {
LOTTransformInterpolator *interpolator = nil;
if (layer.position) {
return [[LOTTransformInterpolator alloc] initWithPosition:layer.position.keyframes
rotation:layer.rotation.keyframes
anchor:layer.anchor.keyframes
scale:layer.scale.keyframes];
interpolator = [[LOTTransformInterpolator alloc] initWithPosition:layer.position.keyframes
rotation:layer.rotation.keyframes
anchor:layer.anchor.keyframes
scale:layer.scale.keyframes];
} else {
interpolator = [[LOTTransformInterpolator alloc] initWithPositionX:layer.positionX.keyframes
positionY:layer.positionY.keyframes
rotation:layer.rotation.keyframes
anchor:layer.anchor.keyframes
scale:layer.scale.keyframes];
}
return [[LOTTransformInterpolator alloc] initWithPositionX:layer.positionX.keyframes
positionY:layer.positionY.keyframes
rotation:layer.rotation.keyframes
anchor:layer.anchor.keyframes
scale:layer.scale.keyframes];
interpolator.parentKeyName = [layer.layerName copy];
return interpolator;
}

- (instancetype)initWithPosition:(NSArray <LOTKeyframe *> *)position
Expand Down

0 comments on commit 3f004a0

Please sign in to comment.