Jump to content
Search Community

MorphSvg mistakes

Andy777 test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts



I am trying to create a simple svg morph that morphs a circle path to a t-shirt path but after the transformation the t-shirt disappear. 


Here is the code: 


<!DOCTYPE html>
        	#hippo {
            	visibility: hidden;
        <svg id="eD8cQxzftYp1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 2000 2000" shape-rendering="geometricPrecision" text-rendering="geometricPrecision">
            <g transform="matrix(.1 0 0-.1 0 2000)">
                <path id="hippo" d="M10810,16308c-170-13-1343-16-1671-4l-246,9-54-25c-30-14-94-58-144-99-149-120-243-176-363-216-236-78-950-359-1372-540-519-223-716-349-1002-640-95-97-113-120-152-204-68-145-258-619-563-1404-36-93-152-388-258-655s-206-523-223-570c-16-47-55-146-85-220-91-227-157-406-157-428c0-14,13-30,38-45c38-25,733-325,1022-442c229-93,529-221,761-325c107-49,204-90,214-92c15-2,29,14,62,72c24,41,48,77,53,78c7,3,10-786,11-2330c2-3556,5-4146,20-4165c18-20,46-30,127-44c95-16,6315-14,6379,3c33,8,47,18,55,37c7,16,14,170,19,401c16,808,30,3690,24,4858-4,718-3,1222,3,1222c5,0,26-29,47-65s41-68,45-70c8-5,259,96,627,254c155,66,333,141,395,167c387,159,1021,443,1046,468c13,13,11,25-20,98-46,106-86,208-197,498-318,829-856,2197-986,2505-112,267-122,283-258,420-216,216-379,331-691,484-321,158-1216,522-1639,667-70,24-142,51-160,60-71,37-186,121-252,184-38,37-86,75-105,85-44,23-160,27-350,13Z"/>
            <path id="circle" class="st1" d="M490.1,280.649c0,44.459-36.041,80.5-80.5,80.5s-80.5-36.041-80.5-80.5s36.041-80.5,80.5-80.5
        <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>
        <script src="src/MorphSVGPlugin.min.js"></script>
        <script type="text/javascript">
            gsap.to("#circle", {morphSVG:"#hippo"})

What i am doing wrong and what is miss in the code?

Link to comment
Share on other sites

It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or CodeSandbox that demonstrates the issue? 


Please don't include your whole project. Just some colored <div> elements and the GSAP code is best (avoid frameworks if possible). See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer.


Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

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


If you're using something like React/Next/Nuxt/Gatsby or some other framework, you may find CodeSandbox easier to use. 


Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

Link to comment
Share on other sites

  • Solution

Your T-shirt was somewhere far outside the canvas of the SVG viewBox and really large (and it was also upside down). I've opened it up in some vector editing software and moved it to the middle of the viewBox and scaled it down a bit. I've also move the circle to the middle, so that it looks like the T-shirt is created form the circle


Working with SVGs on the web requires a bit more setup to make sure all the elements are ready for animating. 


If you are looking for some really simple tool to edit SVG files look at Boxy SVG.  https://boxy-svg.com/app Our @Carl has some great tutorials about it, see https://www.youtube.com/user/snorklTV/videos


See the Pen MWGOJLv by mvaneijgen (@mvaneijgen) on CodePen


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