Jump to content
Search Community

Rotating and TransformOrigin Issues...

cr33ksid3 test
Moderator Tag

Go to solution Solved by cr33ksid3,

Recommended Posts

Hopefully this is a simple enough Pen...

 

So, I'm having trouble with transformOrigin and rotation I think. I thought it would be easy to rotate but as you can see, if you watch long enough,  the center of each ring is off. Now, in my Illustrator SVG, I added a transparent outer ring(circle in the SVG) around each ring so that the grouped object would have a true center. Otherwise, if you have an object that is lopsided, the center would change right? Anyway, even with the clear ring around each ring group the center is still off.

 

What am I missing here?

See the Pen 14e4d97d760572e6234e20836487157c?editors=0010 by cr33ksid3 (@cr33ksid3) on CodePen

Link to comment
Share on other sites

Probably a good time to use svgOrigin.

 

    rings.to("#rings1", {
      duration: 30,
      svgOrigin: "300 300",
      rotation: "+=360",
      repeat: -1
    });

I'd also recommend using the GSAP3 syntax and moving the duration inside the vars. You also don't need the linear ease on each tween since it's a default on the timeline.

 

Happy tweening.

:)

 

  • Like 4
Link to comment
Share on other sites

I know you're still in the early learning stages of GSAP, but I think I'd be remiss in my mod duties if I didn't show you a shorter/easier way to do this. If you just want each ring group to alternate its rotation clockwise/counterclockwise and all the other properties are the same, you can accomplish that with the .wrap() utility method.

 

gsap.to("svg > g", {
  duration: 30,
  rotation: gsap.utils.wrap([360, -360]),
  svgOrigin: "300 300",
  repeat: -1,
  ease: "none"
});

See the Pen e4613d74f3162918e8b74c87f63e877c by PointC (@PointC) on CodePen

 

More info about .wrap()

https://greensock.com/docs/v3/GSAP/UtilityMethods/wrap()

 

I hope that helps. Happy tweening.

:)

 

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