Dovisally Posted February 12, 2021 Share Posted February 12, 2021 Hello there, i do apologize for such a basic simple question i want to know how to organize my gsap code i have 1 example and i want to see how you guy organize that so i will follow the same approach with rest of my code, i do not have any issue with the code i just want to see how do you professionally organize it on for production const tl = gsap.timeline({paused: true}); tl.to('#overlay', { opacity: 1 }) tl.to('#menu', { x: 0, y: 0, z: 0, ease: 'Expo.easeInOut', delay: -1.2, duration: 2 }) tl.to('.menu__line', { x: 0, y: 0, z: 0, delay: -1, duration: 1.5, stagger: 0.1, }) tl.to('.menu__item__content', { x: 0, y: 0, z: 0, stagger: 0.1, delay: -1.5, }) tl.to('.menu__footer__item', { opacity: 1, stagger: 0.1, delay: -1 }) tl.reverse() document.querySelectorAll('.nav__burger').forEach(btn => { btn.addEventListener('click', e => { btn.classList.toggle('active'); tl.reversed(!tl.reversed()) }); }); Link to comment Share on other sites More sharing options...
PointC Posted February 13, 2021 Share Posted February 13, 2021 Hi @Dovisally I think you could benefit from using defaults on the timeline since your x/y/z positions are the same on almost all tweens. You can read about defaults here: https://greensock.com/docs/v3/GSAP/Timeline Rather than using all those negative delays, I'd recommend using the position parameter. More info: Hopefully that helps. Happy tweening. 3 Link to comment Share on other sites More sharing options...
ZachSaucier Posted February 13, 2021 Share Posted February 13, 2021 Additionally your ease is invalid. It should be: ease: 'expo.inOut'. I might also use the reversed property inside of the timeline vars instead of using the reverse method later, but that's more personal preference. 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