Jump to content
GreenSock

Michael Barsotti

get timeline as a string

Recommended Posts

I'm sure this is a very fringe case but is there a way to get a timeline as a string? For example if my javaScript is

var timeline = gsap.timeline();

timeline.set(text1,{autoAlpha:0})

    .addLabel("one","+=1")

    .to(text1,{duration:2,autoAlpha:1},"one");

 

I would like to use something like

console.log(timeline.toString());

and get

timeline.set(text1,{autoAlpha:0}).addLabel("one","+=1").to(text1,{duration:2,autoAlpha:1},"one");

 

Thank you.

Link to comment
Share on other sites

No, sorry, that isn't possible. Animation objects are far more complex than that and can include function-based values, other objects, and many other things, so it's just impossible to convert it all to a string cleanly. You could certainly build a function that parses a timeline and returns as much as possible as a string, but that definitely isn't built-in (it would cost a LOT of kb that almost nobody would use, so it'd be quite wasteful to include it in the core). 

  • Like 1
Link to comment
Share on other sites

That's what I was concluding when i looked inside the timeline and I just gave up LOL. Thanks for responding!

 

P.S. Don't add this feature, it's stupid.

Link to comment
Share on other sites

27 minutes ago, Michael Barsotti said:

P.S. Don't add this feature, it's stupid.

LOL. No, it's not "stupid" at all. I don't blame you for asking. It could be useful in some cases, no doubt. It's just not practical for us to add to the core, that's all. 

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