Jump to content
Search Community

How to optimize code

Fax

Go to solution Solved by ryan_labar,

Recommended Posts

Posted

I am a new programmer and I have been approaching the gsap world for a few days.

In this pen I've tried to operate two different scrolltriggers. It works but I know that is the wrong way.
Could you suggest me a more correct and clean script to activate more triggers scrub mode?

 

Thank you.

See the Pen XWLaeEg by ilpiubello (@ilpiubello) on CodePen.

  • Like 1
Posted

Seen that both tweens need to play at the same time. I would setup one timeline and just add the tweens to that one timeline. Then you can use the position parameter to have both tween start at the same time. Hope it helps and happy tweening! 

 

See the Pen yLdoPmx?editors=0010 by mvaneijgen (@mvaneijgen) on CodePen.

Posted

@mvaneijgen thank for answer.

In your example, there're two path is animating simultaneously, instead I would like to separate the tweens; in fact in my pen there are two timeline (with double markers to personalize points of intersection)...

I don't know if I explained myself well...

Posted

Oh to be it looks like they were doing the same thing, but then there is no need to optimise. If it works, it works!

  • Like 1
Posted
14 hours ago, ryan_labar said:

Hi @Fax

If you're looking to get away from the switch cases (if you had a lot of animations on one page) you could do something like:

 

Yes! This is perfect: clean and concise.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...