Jump to content
Search Community

tl.tweenTo problem

BigApp7e
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

Posted
Hello everyone. I'm AS3 developer and I work with gs libraries before without any problem, but now I start learn js and I'm little confuse about one thing. To be short here is few lines of code:

 

function init(){

            tl = new TimelineMax();          

            tl.append(TweenMax.to(logo,1,{x:200,ease:Linear.easeNone,repeat:-1 ,yoyo:false}));

            tl.addLabel("start",false);

            tl.append(TweenMax.to(logo,1,{x:400,ease:Linear.easeNone}));

            tl.addLabel("end",false);

 

        function onClick()

        {

          tl.tweenTo("end");

 

So I expect this logo to make loop animation to the moment when I click button. When I click I expect timelineMax to move one with next animation and logo have to stop on x=400;

 

Actual result:

When I click the button this logo make few loops backward  and then stop at position x=0;

 

Where I'm wrong?

Can you help me with this 

 

Regards.

Posted

Hi BigApp7e, welcome to the forums!

 

It is quite hard to trouble shoot your case by just looking at a few lines of code. We need some context to try and understand, there could be a lot of things going wrong. For example, it is not clear to me whether you have your onClick() function nested or not into the init() one. That would make a big difference in behaviour.

 

So, if you could get a bare-bones example on CodePen (or anywhere else you might prefer) we can help you out. Carl has a nice post pinned explaining how to create a CodePen.

  • Like 2
Posted

Yes, Dipscom is right about a demo helping.

 

It appears you are adding tweens and labels AFTER a tween that is set to repeat indefinitely (repeat:-1)

 

Seeking past an infinite tween isn't really possible.

 

It sounds like you should be creating a new tween when you click the button and not have it be part of the timeline.

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