Jump to content
Search Community

Can't stop cube rotation on click event

Veil 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

I was trying to create an event of button click which would stop the cube rotation and cause its spinning 90 degrees to the left (if 'left' button clicked) or to the right (if 'right' button clicked) so that the cube turned front strictly with the face, not its edge.  I did it according to the docs, but it won't work.  

See the Pen yoyEzB by anon (@anon) on CodePen

Link to comment
Share on other sites

This adds 90 to the current rotation. So if the rotation is currently at 150, it will tween to 240.

TweenMax.to($('.box__front'), 2, {rotationY:'+=90',   ease:Quad.easeInOut});

 

You need to rotate the faces to some multiple of 90. You can get the rotation of an element like this after a transform has been applied to it.

var rotationY = element._gsTransform.rotationY;

 

And here some pens that might help you out.

See the Pen xryvjZ?editors=0010 by osublake (@osublake) on CodePen

 

See the Pen QNpxEo by osublake (@osublake) on CodePen

 

See the Pen QNppmB?editors=0010 by osublake (@osublake) on CodePen

 

 

  • Like 4
Link to comment
Share on other sites

1 hour ago, OSUblake said:

This adds 90 to the current rotation. So if the rotation is currently at 150, it will tween to 240.


TweenMax.to($('.box__front'), 2, {rotationY:'+=90',   ease:Quad.easeInOut});

 

You need to rotate the faces to some multiple of 90. You can get the rotation of an element like this after a transform has been applied to it.


var rotationY = element._gsTransform.rotationY;

 

And here some pens that might help you out.

See the Pen xryvjZ?editors=0010 by osublake (@osublake) on CodePen

 

See the Pen QNpxEo by osublake (@osublake) on CodePen

 

See the Pen QNppmB?editors=0010 by osublake (@osublake) on CodePen

 

 

 

Thanks for the help, but I already solved this problem on an ordinary Javascript with IE11 support))

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