Jump to content
Search Community

how can I update object of tween onStart?

dominate test
Moderator Tag

Go to solution Solved by Carl,

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

I have a graphic object, let say a box, which is drawn on a html5 canvas, let say its position is (x: 50, y:50).

It is inside another container, whose position is (x:250, y:250).

So, global position of the box is (x:300, y:300).

 

Now, I want to move this box to global (x:100, y:100), and at the beginning I want to move the box from its container, to the global world.

 

So, I try to use onStart, when creating my tween with TweenLite.to. To keep its global position, I set the position of the box in its new parent:

 

onStart: {

  box.setParent(stage);

  box.position.set(300, 300);

}

 

As a result, the parent is set. But, position does not change.

Conclusion: In onStart, I am too late, the box properties was already "somehow" cached by the tween, and that I am changing it does not affect!

 

Question: Is there a way to update properties of the object after/within creating it and just before it starts?

 

Note: lazy: true did not work.

Note: setting the parent of the box before creating tween is not a choice.

 

Example: 

 

Thank you.

See the Pen GoOWBy by anon (@anon) on CodePen

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