Jump to content
Search Community

Transform origin trouble

puffywuffer test
Moderator Tag

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

Was typing this when @PointC replied :) Beat me to it.

 

You could do it programmatically using the getBBox() method of SVG elements to calculate the center and feed that into the svgOrigin. I noticed that circle has a class of .st10 (and it's the only thing with that), so it'd be:

var bounds = document.querySelector(".st10").getBBox(),
    originX = bounds.x + (bounds.width / 2),
    originY = bounds.y + (bounds.height / 2);
TweenLite.set(arm, {svgOrigin: originX + " " + originY});

 

Here's a fork: 

See the Pen db6accebe127acec6e3b3ee68c4dc338 by GreenSock (@GreenSock) on CodePen

 

Note that once you set an svgOrigin or transformOrigin, you don't have to keep setting it in every tween for that same element. GSAP remembers :)

 

Does that help? 

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