Jump to content
Search Community

tweens to play at same time

Lacika1981 test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

 

I need a help to solve my issue.

I have a for loop where I create tweens on a sub timeline that is added to the main timeline. The problem is that each tween that added to the sub timeline played a slight later then the previous one.

 

I have an array with elements `pathElem`.

 

var pathObject = {
  	pathElem: [],
	pathLength: [],
	pathTiming: null,
	};

var tlMain = new TimelineMax();
var tlSub = new TimelineMax();

for( var i = 0; i < chartContainer.length; i++ ) {
	tlMain.add( tlSub.from(pathObject['pathElem'][i], pathObject['pathTiming'][i], {drawSVG: 0}, 0));
	}

tlMain.play();

 

What should I change to play them at the same time?

Link to comment
Share on other sites

 

hmm, this code is a bit unorthodox. Not sure why you are calling from() on tlSub and using that inside an add() for tlMain. Please try this

 

for( var i = 0; i < chartContainer.length; i++ ) {
    tlSub.from(pathObject['pathElem'][i], pathObject['pathTiming'][i], {drawSVG: 0}, 0);
    }

 

that will put all the tweens inside tlSub at a time of 0.

If tlSub needs to be nested in tlMain, then after the loop you can do

 

tlMain.add(tlSub)

 

 

 

In the future, please consider making a demo. It will help us better understand what you are trying to do and provide accurate solutions. thanks

 

 

 

 

 

 

  • Like 3
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...