Jump to content
GreenSock

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

onCompleteParams ripping array elements apart

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

Code

 

The onCompleteParams isn't handling the Array correctly. Each character in the first index of the array is getting split into multiple indexes in the receiving function. I am using the latest version of the library.

Dresden = function () {
	var _that = this;

	this.launch = function (dialogWindow2Launch) {

		switch (dialogWindow2Launch) {
			case ENUM.DIALOG:

				_id('dialogWindowImg').style.backgroundImage="url('assets/svg/gggeeee.svgz'')";
				var twn = TweenMax.to(_id('dialogWindowImg'),1,{ backgroundPosition:'-3200px 0px', ease: SteppedEase.config(10), paused: true});
				//twn.play();
				var arr = [1];
				TweenMax.to(_id('dialogWindow'),0.4,{ y:'200px', ease: Back.easeOut.config(1), onComplete:onLaunchComplete, onCompleteParams:['HELP'] });
				break;
		}
	};

	function onLaunchComplete(dialogWindow2Launch){
		console.log('onLaunchComplete=',dialogWindow2Launch[0], dialogWindow2Launch.length);// OUTPUT = onLaunchComplete= H 4
		switch (dialogWindow2Launch[0]) {
			case ENUM.DIALOG:
				console.log('dialogWindow2Launch=',dialogWindow2Launch, dialogWindow2Launch.length);
				//TweenMax.to(_id('dialogWindowImg'),1,{ backgroundPosition:'-3200px 0px', ease: SteppedEase.config(10)});
				break;
		}
	}
};
Link to comment
Share on other sites

Everything is working as designed from what I can tell:

 

var tween = TweenLite.to("#redBox", 0.5, {x:550, onComplete:complete, onCompleteParams:["bob", 40]})

function complete(name, age) {
  console.log(name, age)
}

 

 http://codepen.io/GreenSock/pen/jPKxGL

 

 

You need to format the onCompleteParams as an Array so that multiple parameters can get into the receiving function.

I think you are expecting the only parameter that gets sent to the receiving function to be an Array.

Does that help?

 

If not, please provide a reduced test case.

  • Like 4
Link to comment
Share on other sites

Posted same time as Carl...

 

You aren't passing an array, you're passing a string. To pass an array, put an array inside the array. You place your params inside the array, but it doesn't actually pass it because it calls Function.prototype.apply().

  • Like 4
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.

×