Waiz Posted June 2, 2023 Share Posted June 2, 2023 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)', } ); } } Link to comment Share on other sites More sharing options...
mvaneijgen Posted June 2, 2023 Share Posted June 2, 2023 Hi @Waiz I've split your question to it's own topic. Do you maybe have a minimal demo we could take a look at? I've you're using React you can use this StackBlitz React template. Also maybe this helps, I'm not a React user, but here are some tips for using GSAP and React Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now