-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Framer Motion and prepare animated counter component
- Loading branch information
1 parent
b934de9
commit 512bec0
Showing
3 changed files
with
60 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use client"; | ||
|
||
import { AnimatePresence, motion } from "framer-motion"; | ||
|
||
interface Props { | ||
value: number; | ||
} | ||
|
||
export const AnimatedCounter = ({ value }: Props) => { | ||
const digits = String(value).split(""); | ||
|
||
return ( | ||
<AnimatePresence mode="popLayout"> | ||
{digits.map((digit, index) => ( | ||
<motion.span | ||
key={index + digit} | ||
initial={{ opacity: 0, y: 20 }} | ||
animate={{ opacity: 1, y: 0 }} | ||
exit={{ opacity: 0, y: -20 }} | ||
transition={{ duration: 0.3, ease: "easeOut" }} | ||
className="relative inline-block text-center" | ||
> | ||
{digit} | ||
</motion.span> | ||
))} | ||
</AnimatePresence> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.