Jump to content
Search Community

Morphing help - cannot morph a <G> SVG element.

Acmafali 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

Hi,

 

I'm trying to morph one SVG to another, the SVG's are ontop of each other. Its an SVG of a brain that morphs into a thumbs up. I keep getting the error:

WARNING: cannot morph a <G> SVG element. Use MorphSVGPlugin.convertToPath(elementOrSelectorText) to convert to a path before morphing.

The brain has an id of #start.

The thumbs up as an id of #end.

 

The thumbs up is hidden in the css.

 

I'm not sure where I'm going wrong, the codepen is attached.

See the Pen WwxvZO by anon (@anon) on CodePen

Link to comment
Share on other sites

Hi Acmafali :)

 

with MorphSVGPlugin you can Morph these SVG tag : <path> <polyline> <polygon> ,  not group of svg elements ( < g > tag )
  
There's a utility function, MorphSVGPlugin.convertToPath() that can convert primitive shapes like <circle>, <rect>, <ellipse>, <polygon>, <polyline>, and <line> directly into the equivalent <path> that looks identical to the original and is swapped right into the DOM.
  • Like 3
Link to comment
Share on other sites

  • 4 years later...
1 hour ago, Electric Circus said:

My SVG is a combination of 4 different SVGs grouped together with individual levels as IDs.
How do I get around this to morph the impression groups into another?

Combine all of the paths in each group into a singular path. Then morph between those paths.

 

Alternatively make sure that each group has the same number of paths and then morph each path into the one with the same index in the next group.

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