Jump to content


Center rotation svg group

Go to solution Solved by Diaco,

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

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

  • Solution

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.