Rio Posted July 7, 2022 Share Posted July 7, 2022 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 More sharing options...
akapowl Posted July 7, 2022 Share Posted July 7, 2022 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 3 Link to comment Share on other sites More sharing options...
Rio Posted July 7, 2022 Author Share Posted July 7, 2022 Thank you so much for clarifying my issue. I think inserting the "angle" with "+=" caused it. This is what I wanted to achieve. Thanks again. See the Pen a64fd835785345304ca1b4ca9ce38772 by riotron (@riotron) on CodePen 3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now