Jump to content
Search Community

Animations at the same time

jonny_max test
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

Somebody help me, please.
I need frase and image start to appear at the same time.

var $farse1 = $("#farse1");
$farse1.html( $farse1.html().replace(/./g, "<span>$&</span>").replace(/\s/g, " "));

var tl = new TimelineMax({alpha:0, repeatDelay:1, repeat:-1});
//var tl = new TimelineMax(); 


//start slide 1
tl.addLabel("end")


 .set( $farse1, {display:'block'},"end" )
 .set( $img1, {display:'block'},"end" )


 .addLabel("end")


 .staggerFromTo( $img1, 0.5, {top:"150px"}, {top:"20px"} )
 .staggerFromTo( $farse1.find("span"), 0.1, {autoAlpha:0}, {autoAlpha:1}, 0.1 )


 .addLabel("end")


 .to( $farse1, 1, {autoAlpha:0},"end" )
 .to( $img1, 1, {autoAlpha:0},"end" )


 .addLabel("end")


 .set( $farse1, {display:'none'},"end" )
 .set( $img1, {display:'none'},"end" );
//end slide 1

 

Link to comment
Share on other sites

I don't know why, but this works wrong
 

				//start slide 1
				tl.addLabel("end")
				  
				  .set( $farse1, {display:'block'},"end" )
				  .set( $img1, {display:'block'},"end" )
				  
				  .addLabel("end")
				  
				  .staggerFromTo( $img1, 0.5, {top:"150px"}, {top:"20px"},"end" );
				
				var i=0;
				$farse1.find("span").each(function(){
					tl.staggerFromTo( this, 0.1, {autoAlpha:0}, {autoAlpha:1,delay:0.1*i},"end" );
					i=i+1;
				});
				
				tl.addLabel("end")
				  
				  .to( $farse1, 1, {autoAlpha:0},"end" )
				  .to( $img1, 1, {autoAlpha:0},"end" )
				  
				  .addLabel("end")
				  
				  .set( $farse1, {display:'none'},"end" )
				  .set( $img1, {display:'none'},"end" );
				//end slide 1

the same story

				var tl = new TimelineMax({alpha:0, repeatDelay:1, repeat:-1});
				//var tl = new TimelineMax();				
				
				//start slide 1
				tl.addLabel("end")
				  
				  .set( $farse1, {display:'block'},"end" )
				  .set( $img1, {display:'block'},"end" )
				  
				  .addLabel("end")
				  
				  .staggerFromTo( $img1, 0.5, {top:"150px"}, {top:"20px"},"end" );
				
				var i=0;
				$farse1.find("span").each(function(){
					tl.staggerFromTo( this, 0.1, {autoAlpha:0}, {autoAlpha:1},"end+=" + i*0.1 );
					i=i+1;
				});
				
				tl.addLabel("end")
				  
				  .to( $farse1, 1, {autoAlpha:0},"end" )
				  .to( $img1, 1, {autoAlpha:0},"end" )
				  
				  .addLabel("end")
				  
				  .set( $farse1, {display:'none'},"end" )
				  .set( $img1, {display:'none'},"end" );
				//end slide 1
Link to comment
Share on other sites

answer: 

				var tl = new TimelineMax({alpha:0, repeatDelay:1, repeat:-1});
				//var tl = new TimelineMax();				
				
				//start slide 1
				tl.addLabel("end")
				  
				  .set( $farse1, {display:'block'},"end" )
				  .set( $img1, {display:'block'},"end" )
				  
				  .addLabel("end")
				  
				  .staggerFromTo( $img1, 0.5, {top:"150px"}, {top:"20px"},"end" );
				
				var i=0;
				$farse1.find("span").each(function(){
					tl.fromTo( this, 0.1, {autoAlpha:0}, {autoAlpha:1},"end+=" + i*0.1 );
					i=i+1;
				});
				
				tl.addLabel("end")
				  
				  .to( $farse1, 1, {autoAlpha:0},"end" )
				  .to( $img1, 1, {autoAlpha:0},"end" )
				  
				  .addLabel("end")
				  
				  .set( $farse1, {display:'none'},"end" )
				  .set( $img1, {display:'none'},"end" );
				//end slide 1
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...