diff --git a/src/components/ui/Transition.tsx b/src/components/ui/Transition.tsx index 509050aec..1e2b298dc 100644 --- a/src/components/ui/Transition.tsx +++ b/src/components/ui/Transition.tsx @@ -51,6 +51,7 @@ const Transition: FC = ({ }) => { // No need for a container to update on change const { animationLevel } = getGlobal().settings.byKey; + const currentIndexRef = useRef(); // eslint-disable-next-line no-null/no-null let containerRef = useRef(null); @@ -145,6 +146,8 @@ const Transition: FC = ({ } function onAnimationEnd() { + if (activeIndex !== currentIndexRef.current) return; + requestAnimationFrame(() => { container.classList.remove('animating', 'backwards'); @@ -180,6 +183,8 @@ const Transition: FC = ({ ? childNodes[activeIndex] && childNodes[activeIndex].firstChild : childNodes[activeIndex]; + currentIndexRef.current = activeKey; + if (animationLevel > 0 && toNode) { waitForAnimationEnd(toNode, onAnimationEnd); } else {