Jump to content
Search Community

Simple way to toggle a div and the svg morphs (toggles between 2 svg)

ChrisZio test
Moderator Tag

Go to solution Solved by Dipscom,

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 and welcome to the GreenSock forums.

 

Thanks for the question.

Morphing SVG paths is super easy with MorphSVGPlugin:

var morph = TweenMax.to("#circle", 1, {morphSVG:"#hippo", repeat:1, yoyo:true, repeatDelay:0.2})

http://codepen.io/GreenSock/pen/17c602b0adb07d2b2ad45b31c6c933af?editors=0010

 

Find out all the details here: https://greensock.com/morphSVG

 

Since you are already a Club GreenSock member you have access to MorphSVG when you download GSAP. 

  • Like 3
Link to comment
Share on other sites

  • Solution

Hi ChrisZio,

 

Let me follow up your message here so others can see the answer, if you don't mind.

 

You asked for more info using MorphSVG on a DIV and how to toggle between two shapes when clicking on a DIV.

 

The info on the MorphSVG will be in the docs and on that link Carl has provided. As to "using MorphSVG on a div", well, that'll be generic JavaScript knowledge. It will be a matter of you wanting to do something and digging around to see what is available. Just like now, creating a toggle.

 

Here's a super bare bones example: 

See the Pen ?editors=1011 by dipscom (@dipscom) on CodePen

 

Hope this helps. :)

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