[Refactoring] Transition: Get rid of redundant scroll-slide animation

This commit is contained in:
Alexander Zinchuk 2021-08-03 19:03:05 +03:00
parent 03b6b9d079
commit 60acbc2f02

View File

@ -16,7 +16,7 @@ type OwnProps = {
ref?: RefObject<HTMLDivElement>;
activeKey: number;
name: (
'none' | 'slide' | 'slide-reversed' | 'mv-slide' | 'slide-fade' | 'zoom-fade' | 'scroll-slide' | 'slide-layers'
'none' | 'slide' | 'slide-reversed' | 'mv-slide' | 'slide-fade' | 'zoom-fade' | 'slide-layers'
| 'fade' | 'push-slide' | 'reveal'
);
direction?: 'auto' | 'inverse' | 1 | -1;
@ -131,14 +131,6 @@ const Transition: FC<OwnProps> = ({
}
});
if (name === 'scroll-slide') {
const width = container.offsetWidth;
container.scrollBy({
left: activeIndex > prevActiveIndex ? width : -width,
behavior: 'smooth',
});
}
let dispatchHeavyAnimationStop: NoneToVoidFunction;
if (animationLevel > 0) {
dispatchHeavyAnimationStop = dispatchHeavyAnimationEvent();
@ -160,10 +152,6 @@ const Transition: FC<OwnProps> = ({
}
});
if (name === 'scroll-slide') {
container.scrollLeft = activeKey * container.offsetWidth;
}
if (shouldRestoreHeight) {
const activeElement = container.querySelector<HTMLDivElement>('.active');
@ -250,7 +238,7 @@ const Transition: FC<OwnProps> = ({
const fullClassName = buildClassName(
'Transition',
className,
animationLevel === 0 && name === 'scroll-slide' ? 'slide' : name,
name,
);
return (