Good Moring everyone
I have this little GSAP function that i wrote to open and close menu on click but the animation only work on second click, i have searched every where none of the provided solution works for me
export function toggleVisibility(targetRef: React.RefObject<HTMLElement>) {
const target = targetRef.current!;
if (target) {
const tl = gsap.timeline();
tl.to(target, {
autoAlpha: target.style?.opacity === '0' ? 1 : 0,
duration: 0.5,
ease: 'power1.easeInOut',
})
.fromTo(
target,
{
y: 20,
scale: 1.2,
},
{
y: 0,
scale: 1,
boxShadow: 'none',
duration: 0.5,
ease: 'elastic.out(2, 0.3)',
}
);
}
}