Jump to content
Search Community

Possible to remove/update timeline items via their position number?

dsiebes test
Moderator Tag

Go to solution Solved by Diaco,

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

This may be more of a feature request, but I'd like to be able to remove items (TimelineMax.remove()) and insert new items (TimelineMax.add()) by position.

 

So if I have a TimelineMax that contains 5 TimelineLite animations, and I want to update the third TimelineLite assuming a zero index:

 

TimelineMax.removebyposition(2);

TimelineMax.addbyposition(myNewTimelineLite,2);

 

Looking at the documentation I can't find a way to do this. I was just wondering if anybody here had any insight in to if this was possible or a planned feature?

 

Thank you!

Dan

 

Link to comment
Share on other sites

Thank you Diaco!

I have read the documentation a number of times, and done a lot of Googling/searching of this site. So I am guessing the feature doesn't exist or I'm just blatantly missing something.

To further explain I can call TimelineMax.remove() but the value I pass needs to be the animation itself that I want to remove. I am wondering, if instead, I can simply pass an index/position per the example in my first post.

Link to comment
Share on other sites

Hello dsiebes,

 

You can store a timeline or tween instance reference by declaring it within a variable. Or like Diaco advised using remove() .. in that case you can add a label on your tween you want removed. Or setup your tween in an instance var.

 

Im sure if you setup a simple codepen demo example we can get a better idea on what your dealing with in context.

 

Here is a great video tut by GreenSock on how to setup a codepen demo example.

 

:)

  • Like 1
Link to comment
Share on other sites

It should be relatively easy to do what you're asking by using the getChildren() method, and if you want to add() another child at the same position as another one, you can just reference its startTime() like:

timeline.add( newChild, otherChild.startTime() ).remove( otherChild );
  • Like 2
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...