Jump to content


Resetting rotation

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

I have a button that, when clicked does



tl = new TimelineLite();
tl.to(photo, 1, {rotationY:-180, z: -500});
tl.to(photo, 1, {rotationY:-360, z: 0});
Trying to figure out how go to get the rotationY at 0 so when clicking the button again, it'll rotate and animate correctly.
Link to comment
Share on other sites

If you always want the animation to start with rotatioY:0


you can put a set() into your timeline




tl.set(photo, {rotationY:0})//same as a tween with a duration of 0 seconds
 .to(photo, 1, {rotationY:-180, z: -500})
 .to(photo, 1, {rotationY:-360, z: 0});

Or the first tween can be  a fromTo() tween




tl.fromTo(photo, 1, {rotationY:0, z:0}, {rotationY:-180, z: -500})
  .to(photo, 1, {rotationY:-360, z: 0});

Or you could simply clear the inline styles that the last tween set




tl.to(photo, 1, {rotationY:-180, z: -500})
  .to(photo, 1, {rotationY:-360, z: 0, clearProps:"all"});


*note this last option assumes that the timeline will always finish before another click happens.


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.