Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
shubhra

Center rotation svg group

Recommended Posts

I want to continuously rotate a group inside the svg. I am applying svgOrigin to the tween, but the group is still not centred while rotating. Also, how do we calculate svgOrigin?

See the Pen EKXWrJ by shubhra (@shubhra) on CodePen

Link to comment
Share on other sites

you can simply use circle cx/cy as svgOrigin reference , so your group center is : svgOrigin: ' 389.74  420.437 '

  • Like 2
Link to comment
Share on other sites

That did it. Thanks a ton!

 

For my understanding, say there was no circle, how do we center the group then? Also, how do we calculate svgOrigin usually?

Link to comment
Share on other sites

Just find the center of whatever you are targeting. So it's own center is...

var bbox = $("#leaves")[0].getBBox();
var cx = bbox.x + bbox.width  / 2;
var cy = bbox.y + bbox.height / 2;
  • Like 5
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.
×