Jump to content
Search Community

How can I rotate Compass to an absolute value?

Rio test
Moderator Tag

Recommended Posts

Following method adds up the value every time the code runs.  When the compass is set to 30degrees first time, that's ok. But when the second time the code runs the rotation value is 45 degrees, the compass point to 75 degrees.

 

gsap.to(".compass", {rotation: 30, duration: 1});

 

How can I make it point to 45 degrees?  

 

Link to comment
Share on other sites

 

Hello @Rio

 

1 hour ago, Rio said:

Following method adds up the value every time the code runs.

 

I'm not 100% sure I fully understand what you mean, but from what I can tell, it really shouldn't / doesn't do add up the value - it would only do that if you used a relative value like "+=30" - if I am not missing something, the code you posted should actually always tween it to 30 - unless you maybe have the initial transforms set on a different element, like a child e.g. but then you tween on the parent.

 

Minimal demos say more than a thousand words, and since you might either mean, do or want something totally different than what is shown in my example (click the body repeatedly to see it always tween to 45), a minimal demo of your scenario would be really appreciated for us to provide you with the best advice possible.

 

See the Pen poLgGZQ by akapowl (@akapowl) on CodePen

 

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