Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
skywolf

onCompleteParams are null for tweenlite

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'm trying to do an infinite random tween using the following code

 

TweenLite.to(box, 2, {left:Math.random() * 600,onComplete:completeHandler, onCompleteParams:box});

 

and the handler is

 

function completeHandler(obj) {
    if (obj)
         TweenLite.to(obj, 2, {left:Math.random() * 600,onComplete:completeHandler, onCompleteParams:obj});
}

 

but after 2 tweens, the parameter becomes null. I can use this.target instead, but there seems to be

a bug

 

thanks

Jon

 

 

 

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

The problem is that the value you specify for onCompleteParams needs to be an array (to support multiple params).

 

try this:

 

 

var box = document.getElementById("box1");


TweenLite.to(box, 1, {left:Math.random() * 600,onComplete:completeHandler, onCompleteParams:[box]});






function completeHandler(obj) {
    if (obj)
         TweenLite.to(obj, 1, {left:Math.random() * 600,onComplete:completeHandler, onCompleteParams:[obj]});
}

 

 

See the Pen ab342c5cfd5a8667b0425d1f4fbfc7d7 by GreenSock (@GreenSock) 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.
×