in ComponentKit/Core/CKComponentAnimations.mm [82:123]
auto animationsForComponents(const ComponentTreeDiff& animatedComponents, UIView *const hostView) -> CKComponentAnimations
{
if (animatedComponents.appearedComponents.empty() &&
animatedComponents.updatedComponents.empty() &&
animatedComponents.disappearedComponents.empty()) {
return {};
}
const auto animationsOnInitialMountPairs = filter(map(animatedComponents.appearedComponents, [](const auto &c) {
return std::make_pair(c, c.animationsOnInitialMount);
}), [](const auto &pair) {
return !pair.second.empty();
});
const auto animationsOnInitialMount =
CKComponentAnimations::AnimationsByComponentMap(animationsOnInitialMountPairs.begin(),
animationsOnInitialMountPairs.end());
const auto animationsFromPreviousComponentPairs = filter(map(animatedComponents.updatedComponents, [](const auto &pair) {
return std::make_pair(pair.current, [pair.current animationsFromPreviousComponent:pair.prev]);
}), [](const auto &pair) {
return !pair.second.empty();
});
const auto animationsFromPrevComponent =
CKComponentAnimations::AnimationsByComponentMap(animationsFromPreviousComponentPairs.begin(),
animationsFromPreviousComponentPairs.end());
const auto animationsOnFinalUnmountPairs = filter(map(animatedComponents.disappearedComponents, [hostView](const auto &c) {
return std::make_pair(c, map(c.animationsOnFinalUnmount, [hostView](const auto &a) {
return CKComponentAnimation {a, hostView};
}));
}), [](const auto &pair) {
return !pair.second.empty();
});
const auto animationsOnFinalUnmount =
CKComponentAnimations::AnimationsByComponentMap(animationsOnFinalUnmountPairs.begin(),
animationsOnFinalUnmountPairs.end());
return {animationsOnInitialMount, animationsFromPrevComponent, animationsOnFinalUnmount};
}