Jump to content
Search Community

Bottle rotation effect

Roman Kovalev test
Moderator Tag

Go to solution Solved by Carl,

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

Hey, there! 
I'm quite a newbie with GSAP and it seems that all I'm making is a chaos in code. 
My goal is to create rotation effect of bottle, so I need to "rotate" the text which goes up and appears from bottom each time the button is pressed. Where to start digging?
 

upd
 

And why does the text invisible on start?

See the Pen JXqroG by NeedHate (@NeedHate) on CodePen

  • Like 1
Link to comment
Share on other sites

  • Solution

Hi,

 

Thanks for the demo. You are doing a fine job.

 

This is a bit of a tricky situation since you have 2 fromTo() tweens that are fighting to set the from position at the same time.

 

Solution is to put immediateRender:false on the second tween

 

tl.fromTo(element, 0.75, {y: 0,rotationX: 0, scale: 1}, {y: -200,rotationX: -90, scale: .75, ease:Expo.easeOut})
.fromTo(element, 0.75, {y: 200,rotationX: 90, scale: .75}, {y: 0,rotationX: 0, scale: 1, ease:Expo.easeOut, immediateRender:false});
 
And once that is in place, the first tween can just be a to() tween
 
 
var tl = new TimelineMax({paused: true}); 


tl.to(element, 0.75,  {y: -200,rotationX: -90, scale: .75, ease:Expo.easeOut})
.fromTo(element, 0.75, {y: 200,rotationX: 90, scale: .75}, {y: 0,rotationX: 0, scale: 1, ease:Expo.easeOut, immediateRender:false});

Demo: http://codepen.io/GreenSock/pen/jqjEQz?editors=0010

 
ImmediateRender Demystified
 
 
lastly, reversed isn't a valid property to go in the TimelineLite constructor
 
//bad
var tl = new TimelineLite({reversed:true});




//good
var tl = new TimelineLite({});


tl.to(element, 1, {...})


tl.reverse()
//or
tl.reversed(true);
In your demo I don't think you need to have it reversed at the beginning, but just wanted to point it out.
  • 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.
×
×
  • Create New...