Transition: Fixes for frozen heavy animation

This commit is contained in:
Alexander Zinchuk 2021-08-17 01:54:25 +03:00
parent 03eaacf5aa
commit dea730f573
2 changed files with 11 additions and 33 deletions

View File

@ -23,32 +23,6 @@
transition: none !important;
}
/*
* scroll-slide
*/
&.scroll-slide {
width: 100%;
height: 100%;
overflow: hidden;
display: flex;
flex-wrap: nowrap;
> * {
position: static;
flex-shrink: 0;
&:not(.active):not(.from):not(.to) {
display: block !important;
transform: scale(0);
&.through {
display: none !important;
}
}
}
}
/*
* slide
*/

View File

@ -51,7 +51,7 @@ const Transition: FC<OwnProps> = ({
}) => {
// No need for a container to update on change
const { animationLevel } = getGlobal().settings.byKey;
const currentIndexRef = useRef<number>();
const currentKeyRef = useRef<number>();
// eslint-disable-next-line no-null/no-null
let containerRef = useRef<HTMLDivElement>(null);
@ -147,7 +147,9 @@ const Transition: FC<OwnProps> = ({
function onAnimationEnd() {
requestAnimationFrame(() => {
if (activeIndex !== currentIndexRef.current) return;
if (activeKey !== currentKeyRef.current) {
return;
}
container.classList.remove('animating', 'backwards');
@ -179,14 +181,16 @@ const Transition: FC<OwnProps> = ({
});
}
const toNode = name === 'mv-slide'
const watchedNode = name === 'mv-slide'
? childNodes[activeIndex] && childNodes[activeIndex].firstChild
: childNodes[activeIndex];
: name === 'reveal' && isBackwards
? childNodes[prevActiveIndex]
: childNodes[activeIndex];
currentIndexRef.current = activeKey;
currentKeyRef.current = activeKey;
if (animationLevel > 0 && toNode) {
waitForAnimationEnd(toNode, onAnimationEnd);
if (animationLevel > 0 && watchedNode) {
waitForAnimationEnd(watchedNode, onAnimationEnd);
} else {
onAnimationEnd();
}