Transition: Fix exception when missing node

This commit is contained in:
Alexander Zinchuk 2021-08-06 03:25:21 +03:00
parent 71c067e751
commit 18fa93365c

View File

@ -140,6 +140,10 @@ const Transition: FC<OwnProps> = ({
requestAnimationFrame(() => { requestAnimationFrame(() => {
container.classList.add('animating'); container.classList.add('animating');
if (onStart) {
onStart();
}
function onAnimationEnd() { function onAnimationEnd() {
requestAnimationFrame(() => { requestAnimationFrame(() => {
container.classList.remove('animating', 'backwards'); container.classList.remove('animating', 'backwards');
@ -172,16 +176,15 @@ const Transition: FC<OwnProps> = ({
}); });
} }
if (animationLevel > 0) { const toNode = name === 'mv-slide'
const toNode = name === 'mv-slide' ? childNodes[activeIndex].firstChild! : childNodes[activeIndex]; ? childNodes[activeIndex] && childNodes[activeIndex].firstChild
: childNodes[activeIndex];
if (animationLevel > 0 && toNode) {
waitForAnimationEnd(toNode, onAnimationEnd); waitForAnimationEnd(toNode, onAnimationEnd);
} else { } else {
onAnimationEnd(); onAnimationEnd();
} }
if (onStart) {
onStart();
}
}); });
}, [ }, [
activeKey, activeKey,