Prevent animating scroll view on initial mount

This commit is contained in:
Luke Vella 2022-04-17 08:51:01 +01:00
parent 7733155746
commit f30505e1f8

View file

@ -41,17 +41,19 @@ export const ControlledScrollDiv: React.VoidFunctionComponent<{
className={clsx(" min-w-0 overflow-hidden", className)}
style={{ width: availableSpace, maxWidth: availableSpace }}
>
<motion.div
className="flex h-full"
transition={{
type: "spring",
mass: 0.4,
}}
initial={{ x: 0 }}
animate={{ x: scrollPosition * -1 }}
>
{children}
</motion.div>
<AnimatePresence initial={false}>
<motion.div
className="flex h-full"
transition={{
type: "spring",
mass: 0.4,
}}
initial={{ x: 0 }}
animate={{ x: scrollPosition * -1 }}
>
{children}
</motion.div>
</AnimatePresence>
</div>
);
};