Skip to content

Commit

Permalink
Added converting codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
devedbox committed Apr 1, 2017
1 parent 8a677fe commit 08cde4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (nullable instancetype)animationWithBasic:(nullable CABasicAnimation *)basicAnimation;
/// Convert animation from CABasicAnimation using custom values function.
///
+ (nullable instancetype)animationWithBasic:(nullable CABasicAnimation *)basicAnimation usingValuesFunction:(nullable double (^)(double t, double b, double c, double d))valuesFunction;
+ (nullable instancetype)animationWithBasic:(nullable CABasicAnimation *)basicAnimation usingValuesFunction:(CAKeyframeValuesFunction _Nullable)valuesFunction;
/// Convert animation from SpringAnimation.
///
/// @param animation spring animation to convert.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ id CalculateToValueWithByValue(id value, id byValue, BOOL plus) {
}

@implementation CAKeyframeAnimation (Convertable)
+ (instancetype)animationWithBasic:(CABasicAnimation *)basicAnimation usingValuesFunction:(double (^)(double, double, double, double))valuesFunction {
+ (instancetype)animationWithBasic:(CABasicAnimation *)basicAnimation usingValuesFunction:(CAKeyframeValuesFunction)valuesFunction {
if (!basicAnimation) return nil;
CAKeyframeAnimation *keyframe = [CAKeyframeAnimation animation];
keyframe.beginTime = basicAnimation.beginTime;
Expand Down Expand Up @@ -476,6 +476,11 @@ + (instancetype)animationWithBasic:(CABasicAnimation *)animation {
@end

@implementation AXDecayAnimation (Convertable)
+ (instancetype)animationWithBasic:(CABasicAnimation *)basicAnimation usingValuesFunction:(CAKeyframeValuesFunction)valuesFunction {
if (!basicAnimation || ![basicAnimation isKindOfClass:CAKeyframeAnimation.class]) return nil;
return [super animationWithBasic:basicAnimation usingValuesFunction:valuesFunction];
}

+ (instancetype)animationWithSpring:(AXCASpringAnimation *)animation {
return [self animationWithBasic:animation];
}
Expand Down

0 comments on commit 08cde4b

Please # to comment.