in ComponentKit/Core/CKComponentAnimation.mm [51:80]
static CKComponentAnimationHooks hooksForFinalUnmountAnimation(const CKComponentFinalUnmountAnimation &a,
UIView *const hostView) noexcept
{
const auto component = a.component;
CAAnimation *const animation = [a.animation copy];
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
return CKComponentAnimationHooks {
.willRemount = ^() {
const auto viewForAnimation = [component viewForAnimation];
RCCAssertWithCategory(viewForAnimation != nil, [component className],
@"Can't animate component without a view. Check if %@ has a view.", [component className]);
const auto snapshotView = [viewForAnimation snapshotViewAfterScreenUpdates:NO];
snapshotView.layer.anchorPoint = viewForAnimation.layer.anchorPoint;
snapshotView.frame = [viewForAnimation convertRect:viewForAnimation.bounds toView:hostView];
snapshotView.userInteractionEnabled = NO;
return snapshotView;
},
.didRemount = ^(UIView *const snapshotView){
[hostView addSubview:snapshotView];
auto const animationAddTime = [snapshotView.layer convertTime:CACurrentMediaTime() fromLayer:nil];
animation.beginTime += animationAddTime;
[snapshotView.layer addAnimation:animation forKey:nil];
return snapshotView;
},
.cleanup = ^(UIView *const snapshotView){
[snapshotView removeFromSuperview];
}
}.byAddingCompletion(a.completion);
}