feat:Add iOS animation callback
This commit is contained in:
parent
a94ed4d880
commit
b12930605e
@ -66,6 +66,17 @@ CGPathRef DoricCreateRoundedRectPath(CGRect bounds,
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@interface AnimationCallback : NSObject <CAAnimationDelegate>
|
||||||
|
@property(nonatomic, strong) void (^endBlock)();
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation AnimationCallback
|
||||||
|
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
|
||||||
|
if (self.endBlock) {
|
||||||
|
self.endBlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@interface DoricViewNode ()
|
@interface DoricViewNode ()
|
||||||
@property(nonatomic, strong) NSMutableDictionary *callbackIds;
|
@property(nonatomic, strong) NSMutableDictionary *callbackIds;
|
||||||
@ -314,6 +325,12 @@ - (void)doAnimation:(id)params withPromise:(DoricPromise *)promise {
|
|||||||
CAAnimation *animation = [self parseAnimation:params];
|
CAAnimation *animation = [self parseAnimation:params];
|
||||||
animation.removedOnCompletion = NO;
|
animation.removedOnCompletion = NO;
|
||||||
animation.fillMode = kCAFillModeForwards;
|
animation.fillMode = kCAFillModeForwards;
|
||||||
|
AnimationCallback *animationCallback = [[AnimationCallback new] also:^(AnimationCallback *it) {
|
||||||
|
it.endBlock = ^{
|
||||||
|
[promise resolve:nil];
|
||||||
|
};
|
||||||
|
}];
|
||||||
|
animation.delegate = animationCallback;
|
||||||
[self.view.layer addAnimation:animation forKey:nil];
|
[self.view.layer addAnimation:animation forKey:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user