Jump to content
GreenSock

Ivan

Function in function

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

Hello everybody!
Can't understand why GSAP animate only first transition (rotate).
Second transition it's made, but witout animation, as if duration changes to 0.
Thanks for any help!
 
link for project:

http://htmlfabric.ru/test/club.2/

 

UPD: js code:

var
		tl = new TimelineMax({ onComplete: changePhotos }),
		photoContainer = $('#container'),
		footContainer = $('#foot__container'),
		needDelay = 1,
		fadeTime = 1.5,
		piBlock = $('.pi__block'),
		allItems = $('.pi__img'),
		logoItems = $('.pii--logo');
	
	//fade in & out
	function logo() {
		
		tl//.staggerTo(logoItems, fadeTime, { autoAlpha: 1, delay: needDelay }, 0.2)
		//.to(allItems, fadeTime*1.5, { autoAlpha: 1, delay: needDelay })
		//.staggerTo(logoItems, fadeTime, { autoAlpha: .35, delay: needDelay }, 0.2)
		//.to(allItems, fadeTime*1.5, { autoAlpha: .35, delay: needDelay });
		.to(allItems, 1, { delay: needDelay })
		
	}
	logo();
	
	//change photos
	var
		sideA,
		sideB,
		sideAnumber = 0,
		sideBnumber = 1;
	
	function changePhotos() {

		sideAnumber += 1;
		sideBnumber += 1;
		
		sideA = $('.side'+sideAnumber);
		sideB = $('.side'+sideBnumber);
		
		tl.to(sideB, fadeTime*0.5, { autoAlpha: 1, delay: needDelay, rotationY: '+=180deg', transformOrigin: '50% 50% 50px' }, 'together')
		.to(sideA, fadeTime*0.5, { autoAlpha: 0, delay: needDelay, rotationY: '-=180deg', transformOrigin: '50% 50% 50px' }, 'together');
		
		logo();
	}
Link to comment
Share on other sites

Hello

 

Im trying to follow your link from above to your project site.. but the site is really slow and im getting this error in the console:

ReferenceError: head is not defined
head.js('http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js')

http://htmlfabric.ru/test/club/js/js_attach.js LINE 1
Link to comment
Share on other sites

you could run each block through a for loop or jQuery each() and apply the auto increment.. or if your are using PHP you could have it auto increment server side before page load..

 

do you have a limited test case example set up via jsfiddle or

See the Pen by pen (@pen) on CodePen

so we can see the context with your JS, CSS, and HTML :)

Link to comment
Share on other sites

Great thanks..

 

you might have to make your image paths absolute (ie.. so they have the full path to the image).. jsfiddle is throwing not found image errors in the console..

Link to comment
Share on other sites

The problem was in Label (in my case "together")

For each timeline i update it and its work!

 

tl.to(sideB, fadeTime*0.5, { autoAlpha: 1, delay: needDelay, rotationY: '+=180deg', transformOrigin: '50% 50% 50px' }, 'together')
  • Like 2
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.
×