I am trying to use the GSAP CSS Rule Plugin to target and animate a pseudo selector. The problem is that it doesn't detect it and logs GSAP target undefined not found to the console. I tried to get the element by logging the element to the console but it is also undefined.
Here is how I am using it:
import { gsap } from "gsap"
import { CSSRulePlugin } from "gsap/CSSRulePlugin"
const IndexPage = () => {
useEffect(() => {
gsap.registerPlugin(CSSRulePlugin);
const titleRule = CSSRulePlugin.getRule(
"span.landing__title--span::after"
)
// Log titleRule
console.log(titleRule). // undefined
const tl = gsap.timeline();
tl.to(
titleRule,
{
cssRule: {
scaleY: 0,
duration: 1
},
}
)
},[])
return (
<div>
<span className="landing__title--span">Hey there</span>
</div>
)
}
export default IndexPage
What am I doing wrong and how do I rectify it? Thanks in advance