From 433e74b7c9ff309f5593825d81a86524488e55d4 Mon Sep 17 00:00:00 2001 From: Maxwell Barvian Date: Sat, 23 Nov 2024 10:50:46 -0800 Subject: [PATCH] Better Motion arrow canAnimate --- .../examples/_Motion/react/Component.tsx | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/site/src/pages/[...framework]/examples/_Motion/react/Component.tsx b/site/src/pages/[...framework]/examples/_Motion/react/Component.tsx index 7a27cdf..80e2a20 100644 --- a/site/src/pages/[...framework]/examples/_Motion/react/Component.tsx +++ b/site/src/pages/[...framework]/examples/_Motion/react/Component.tsx @@ -1,4 +1,4 @@ -import { motion, MotionConfig, MotionContext } from 'motion/react' +import { motion } from 'motion/react' import NumberFlow, { useCanAnimate } from '@number-flow/react' import { ArrowUp } from 'lucide-react' import clsx from 'clsx/lite' @@ -15,35 +15,35 @@ export default function MotionExample({ value }: Props) { const canAnimate = useCanAnimate() return ( - - 0 ? 'bg-emerald-400' : 'bg-red-500', - '~text-base/2xl inline-flex items-center px-[0.3em] text-white transition-colors duration-300' - )} - style={{ borderRadius: 999 }} + 0 ? 'bg-emerald-400' : 'bg-red-500', + '~text-base/2xl inline-flex items-center px-[0.3em] text-white transition-colors duration-300' + )} + style={{ borderRadius: 999 }} + layout={canAnimate} + transition={{ layout: { duration: 0.9, bounce: 0, type: 'spring' } }} + > + 0 ? 0 : -180 }} + initial={false} + /> + - 0 ? 0 : -180 }} - initial={false} - /> - - - + layoutRoot={canAnimate} + /> + ) }