Jump to content
Search Community

Getting current rotation of object

kaidean test
Moderator Tag

Go to solution Solved by kaidean,

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

Hello all, I am new around these parts and I am having a slight issue...


Is there a way for me to get the current rotation of an object? I am making a spinning wheel activity, I want the wheel to spin at least twice before settling in its final position, for the first spin this works fine but after that it just rotates round to the next stop rather than going round twice first.


Currently the code I am using is:


rotation:(degArray[a] + minSpin) + "_cw"


"degArray" is where the randomised values are stored and "minSpin" is a variable set earlier (currently set to 720).  What I feel I should be able to do is something like this:


rotation:(currentRotation + degArray[a] + minSpin) + "_cw"


I am using this in JS within Adobe Edge Animate.


Thanks in advance



Link to comment
Share on other sites

  • Solution


Hi kaidean  :)


you can get current roation value by this : element._gsTransform.rotation


for example :


console.log( document.getElementById("Stage_Ellipse")._gsTransform.rotation );


Perfect, thanks a lot!

Link to comment
Share on other sites

  • 8 years later...

For anyone finding this thread via Google (like I did): the GSAP 3 way to get the same property is to use _gsap rather than _gsTransform:


Note that this returns the CSS-transform style value, e.g. '45deg', so you'll want to either parseInt() or parseFloat() that if you want just the number.

There may well be a neater GSAP-utilities way to do it, but this was all I needed for a quick on-the-fly calculation.

Link to comment
Share on other sites

@indextwo I can totally see why you'd suggest that, and thanks for updating this old thread but you should never tap directly into a property that begins with "_" because that's indicating that it's "private" (could change in future versions, etc.)


The proper way to do this in GSAP 3 is to use gsap.getProperty()

gsap.getProperty("#my_element", "rotation");

Does that clear things up? 

  • Like 3
Link to comment
Share on other sites

I knew there was a proper way to do it! And this is helpful for future reference.

I was using it in an onEvent callback just to see what the 'over' rotation was when I used an ease like back.out(1.7) - it was just a quick & dirty piece of code to see what that value was on the console before I deleted it.

(Also I'm positive I've used getProperty in other code before - it's just so long between gsap projects for me that I forget!)

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