Skip to content

Commit

Permalink
Animating hero wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Taxato committed May 14, 2024
1 parent da3fb07 commit 17be8fe
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/components/sections/Hero.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
import { animate, motion, useMotionValue, useTransform } from "framer-motion";
import Code from "../Code";
import { useEffect } from "react";

export default function Hero() {
const letterCount = useMotionValue(0);
const baseText = "Hi I'm Thomas";

useEffect(() => {
const controls = animate(letterCount, baseText.length, {
type: "tween",
duration: 1,
ease: "linear",
});
return controls.stop;
}, [letterCount]);

const rounded = useTransform(letterCount, latest => Math.round(latest));
const titleText = useTransform(rounded, latest =>
baseText.slice(0, latest),
);

return (
<div className="mb-24 mt-24 text-center text-white">
<h1 className="font-tech text-4xl font-bold sm:text-6xl ">
Hi, I&apos;m Thomas
</h1>
<motion.h1 className="font-tech text-4xl font-bold sm:text-6xl ">
{titleText}
</motion.h1>
<p className="pt-2 text-lg tracking-wide">
A front-end <Code>web</Code> developer.
</p>
Expand Down

0 comments on commit 17be8fe

Please sign in to comment.