make animation faster
All checks were successful
Deploy SSR / deploy (push) Successful in 1m12s

This commit is contained in:
Lee 2024-09-12 23:31:56 +01:00
parent e60a14e799
commit b8311ad1ec

@ -28,6 +28,24 @@ const scoreSort = [
}, },
]; ];
const scoreAnimation: Variants = {
hiddenRight: {
opacity: 0,
x: 50,
},
hiddenLeft: {
opacity: 0,
x: -50,
},
visible: {
opacity: 1,
x: 0,
transition: {
staggerChildren: 0.03,
},
},
};
type Props = { type Props = {
initialScoreData?: ScoreSaberPlayerScoresPage; initialScoreData?: ScoreSaberPlayerScoresPage;
player: ScoreSaberPlayer; player: ScoreSaberPlayer;
@ -35,42 +53,6 @@ type Props = {
page: number; page: number;
}; };
const containerVariants: Variants = {
hiddenRight: {
opacity: 0,
x: 50,
},
hiddenLeft: {
opacity: 0,
x: -50,
},
visible: {
opacity: 1,
x: 0,
transition: {
staggerChildren: 0.05,
},
},
};
const childVariants: Variants = {
hiddenRight: {
opacity: 0,
x: 50,
},
hiddenLeft: {
opacity: 0,
x: -50,
},
visible: {
opacity: 1,
x: 0,
transition: {
ease: "anticipate",
},
},
};
export default function PlayerScores({ initialScoreData, player, sort, page }: Props) { export default function PlayerScores({ initialScoreData, player, sort, page }: Props) {
const { width } = useWindowDimensions(); const { width } = useWindowDimensions();
const controls = useAnimation(); const controls = useAnimation();
@ -145,11 +127,11 @@ export default function PlayerScores({ initialScoreData, player, sort, page }: P
<motion.div <motion.div
initial="hidden" initial="hidden"
animate={controls} animate={controls}
variants={containerVariants} variants={scoreAnimation}
className="grid min-w-full grid-cols-1 divide-y divide-border" className="grid min-w-full grid-cols-1 divide-y divide-border"
> >
{currentScores.playerScores.map((playerScore, index) => ( {currentScores.playerScores.map((playerScore, index) => (
<motion.div key={index} variants={childVariants}> <motion.div key={index} variants={scoreAnimation}>
<Score playerScore={playerScore} /> <Score playerScore={playerScore} />
</motion.div> </motion.div>
))} ))}