Jump to content
Search Community

ScrollTrigger reverse animation when complete

Metriakon test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi :) I have a problem with reverse animation after finishing.

I get this animation from examples.

Ex. i want to play animation in Timeline and onComplete i want to play the same animation in reverse.

 

const timeline = gsap.timeline({ 
  paused: true,
  scrollTrigger: {
    trigger: 'section',
    start: '0px',
    end: '+=200%',
    pin:true,
    scrub: true   
  }
})

const t1 = gsap.timeline({ repeat:0, repeatDelay:0})
.to('.logo',1,{y:-100+'%'})  


   
  
  
  timeline
  .add('SECTION_0')
  .add(t1)
  .addPause()
  .add('SECTION_1')
  .to('.m', {duration:(i)=>[0.8,1.3][i], y:-10266, ease:'steps(29)', stagger:-0.3}, 0) // THIS ANIMATION
  .to('.box', {duration:2, scale:1.1, transformOrigin:'50% 50%', ease:'power2'}, 0) // THIS ANIMATION
  .addPause()
  .add('SECTION_2')
	//THEN I WANT TO REVERSE ANIMATION THERE
  .to('.mainimg-wrapper',1,{x:100+'%'},'SECTION_2')
  .addPause()

 

 

See the Pen YzqWVKP by creativeocean (@creativeocean) on CodePen

Link to comment
Share on other sites

11 hours ago, GreenSock said:

There are many ways to do this, but if you just want it to play forward once and then backward once, all you need to do is set repeat: 1, yoyo: true on your animation. Is that what you're looking for? 

Ough, yeah thats help :) Thanks for  answer and sorry for a probably silly question due to my poor English proficiency..

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