Jump to content
Search Community

Rotating a cube on one axis goes in random directions

stillLogan test
Moderator Tag

Go to solution Solved by PointC,

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

Hi,

 

I have been stuck on this for a while now.

 

I would like for this cube to rotate from right to left through all 4 sides. The problem is it goes from 0 to -90, then from -90 to -180, in the correct direction, after that it does a full rotation to get to -270, and then again a full rotation to get to -359.

 

The

See the Pen ZLXJGq by stillLogan (@stillLogan) on CodePen

 is my attempt at using the DirectionalRotationPlugin, but i dont think it was designed for this.

 

Has anyone got an idea how to make it go in one direction.

 

thanks!

 

codePen:

See the Pen ZLXJGq by stillLogan (@stillLogan) on CodePen

Link to comment
Share on other sites

Hi stillLogan :)

 

Welcome to the GreenSock forum.

 

Your CodePen is not actually loading the DirectionalRotationPlugin. You've loaded TweenLite, CSSPlugin, TimelineLite and the EasePack. You can simplify things by loading Tweenmax which will include:

  • TweenLite
  • TweenMax
  • TimelineLite
  • TimelineMax
  • CSSPlugin
  • AttrPlugin
  • RoundPropsPlugin
  • DirectionalRotationPlugin
  • BezierPlugin
  • EasePack
https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js

You also have a small error on the position parameter:

//please switch this
timeline_1.to(carousel, 0.5, {rotationY: "-180_short", ease:Sine.easeInOut}, "=+1");

// to this
timeline_1.to(carousel, 0.5, {rotationY: "-180_short", ease:Sine.easeInOut}, "+=1");

I think everything should work correctly with those changes and loading all the necessary files.

 

Hopefully that helps.

 

Happy tweening and welcome aboard.

:)

  • Like 1
Link to comment
Share on other sites

  • Solution

I just noticed you also have a CSS transition on line 15 of your stylesheet

// remove this on line 15 of your CSS
transition: transform 1s;

This is causing a fight for control between CSS and GSAP. Once you remove that line, your animation will work as expected. It's never a good idea to mix CSS animations with GSAP. You can get problems exactly like this one.

 

Happy tweening.

:)

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