Hello, I wanted to create an animation with GSAP to make a text fade in from the center out
So I tried to do it and got the following code:
Feature.astro
<script>
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
gsap.registerPlugin(ScrollTrigger);
gsap.timeline({
scrollTrigger: {
trigger: ".feature",
start: "center bottom",
end: "bottom bottom",
scrub: true,
},
}).to(".feature", {
"--progress": "0%",
});
</script>
<div class="feature max-w-[25%]">
<h2 class="text-8xl font-heading font-semibold">
Dummy Text (longer)
</h2>
</div>
<style>
.feature {
--progress: 100%;
mask-image: radial-gradient(
circle at center,
transparent,
#fff var(--progress)
);
mask-size: 200%;
}
</style>
And while it works, it has two issues:
- At the start of the animation, the edges of the text are visible
- As it is a gradient, there isn't a clear division between appeared and disappeared
Can you help me solve this issues?