Jump to content
Search Community

All Master Timeline Animation Start Once Loaded

shunyadezain test
Moderator Tag

Recommended Posts

Hi everyone. I have a trouble with master timeline.

I can't figure out why all animations in master timeline start when content loaded.

 

I want two animations of the computer to switch each 5~7 seconds . It works fine after the delay finishes.

There are Mater timeline on the bottom of codes and functions are top of it.

 

Could you give me some advises to fix this problem?

Thank you.

See the Pen PoNOJMR?editors=1010 by shunyadezain (@shunyadezain) on CodePen

Link to comment
Share on other sites

Your frist problem is that you're returning the function it self not the time line 

 

function sw1() {
  var switchTl1 = gsap.timeline();
  // return sw1; // ️ name of the function 
  return switchTl1 //  name of the timeline
}

 

Over alI would create a master timeline (you already have that) and create functions of all your animations like you do with `sw1` and `sw2`, but do it also for the keyboard and the coding on the screen and add all those animations to the masterTime line.

 

Right now there are all kinds of animations that are either playing or not, but are somehow hidden ( I don't know what that means for performance, but I would not animate things that are not visible)

  • Like 4
Link to comment
Share on other sites

Thank you so much! @mvaneijgen I did not notice that.

 

Some animations were not working after fixing the problem.

But I used eventCallback() in the functions and now it's working! 😁

 

  function sw1(e) {
    const switchTl1 = gsap.timeline();

    switchTl1.eventCallback("onUpdate", function () {
		keyBtnMove.pause();
    });

    return switchTl1;
  }

 

Link to comment
Share on other sites

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...