Jump to content
Search Community

MorphSVGPlugin

Parvathy test
Moderator Tag

Recommended Posts

Complete beginner to HTML/CSS/JS, SVG, GSAP and wanted to try a simple morph with the MorphSVGPlugin. Morphing does occur, but the positioning is off. Not quite sure what I am doing wrong. The rectangle on the right(or bottom) contains the begin state(smaller triangles) and the end state(bigger triangles). The left(or top) rectangle is what I get using the plugin. Any feedback would be appreciated. Thank you.

See the Pen rNxyJBb by paro1979 (@paro1979) on CodePen

Link to comment
Share on other sites

Hey Parvathy and welcome to the GreenSock forums. Thanks for supporting GreenSock by being a Club GreenSock member!

 

First off, we recommend using GSAP 3 syntax. It's sleeker and less confusing :) See this post for more info:

 

The main issue here is that you've got transforms on your SVG elements so it looks like the correct morph isn't happening but it is. MorphSVG can't factor those into the calculations. If you don't need the transforms, just get rid of them. If you do, then use a vector editor like Illustrator or Inkscape to bake the transforms into the actual element's positioning instead. It might be helpful to just make them all paths in the editor because that's what MorphSVG uses.

 

With that being said, MorphSVG has a handy .convertToPath() method that can convert the polygons to paths if needed.

See the Pen PoZpLOg?editors=1000 by GreenSock (@GreenSock) on CodePen

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