Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="menuWrapper">
  <div class="menuItem" onclick={goTo('#home')}>Home</div>
  <div class="menuItem" onclick={goTo('#about')}>About</div>
</div>

<div class="mainWrapper"> 
<svg
          width="100%"
          height="100%"
          viewBox="0 0 300 80"
          version="1.1"
        >
          <path
            id="home"
            d="M29.969,40.688l-5.938,-0.001c0.209,-7.208 0.313,-13.666 0.313,-19.375l-18.719,0c0,4.625 0.104,11.084 0.313,19.375l-5.938,0c0.292,-7.604 0.438,-14.729 0.438,-21.375c-0,-6.958 -0.146,-13.395 -0.438,-19.312l5.938,-0c-0.25,5.958 -0.375,11.75 -0.375,17.375l18.843,-0c0,-4.521 -0.125,-10.313 -0.375,-17.375l5.938,-0c-0.313,5.792 -0.469,12.229 -0.469,19.312c0,7.771 0.156,14.896 0.469,21.375Z M68.5,24.938c0,5.333 -1.531,9.494 -4.594,12.484c-3.062,2.989 -6.666,4.484 -10.812,4.484c-3.875,0 -7.203,-1.323 -9.985,-3.968c-2.781,-2.646 -4.172,-6.376 -4.172,-11.188c0,-5.375 1.537,-9.573 4.61,-12.594c3.073,-3.021 6.682,-4.531 10.828,-4.531c3.875,0 7.198,1.339 9.969,4.016c2.771,2.677 4.156,6.442 4.156,11.297Zm-5.406,1.093c-0,-3.25 -0.818,-6.14 -2.453,-8.672c-1.636,-2.531 -3.964,-3.797 -6.985,-3.797c-3,0 -5.307,1.198 -6.922,3.594c-1.614,2.396 -2.422,5.177 -2.422,8.344c0,3.271 0.818,6.167 2.454,8.688c1.635,2.52 3.974,3.781 7.015,3.781c3,-0 5.302,-1.203 6.907,-3.61c1.604,-2.406 2.406,-5.182 2.406,-8.328Z M114.969,22.594c-0,-3.334 -0.578,-5.537 -1.735,-6.61c-1.156,-1.073 -3.057,-1.609 -5.703,-1.609c-2.229,-0 -4.531,1.094 -6.906,3.281c-0.083,2.542 -0.125,5.031 -0.125,7.469c0,3.479 0.063,8.667 0.188,15.562l-5.688,0c0.458,-5.937 0.688,-11.968 0.688,-18.093c-0,-3.334 -0.579,-5.537 -1.735,-6.61c-1.156,-1.073 -3.005,-1.609 -5.547,-1.609c-2.604,-0 -5.041,1.094 -7.312,3.281c-0,6.604 0.041,14.281 0.125,23.031l-5.688,0c0.396,-7.083 0.594,-12.208 0.594,-15.375c0,-4.812 -0.469,-9.541 -1.406,-14.187l5.5,-0.781l0.562,3.781l0.313,-0c2.708,-2.771 5.719,-4.156 9.031,-4.156c4.938,-0 8.115,1.385 9.531,4.156l0.344,-0c3.146,-2.771 6.25,-4.156 9.313,-4.156c3.5,-0 6.145,0.771 7.937,2.312c1.792,1.542 2.688,4.261 2.688,8.156c-0,0.396 -0.021,1.178 -0.063,2.344c-0.042,1.167 -0.062,1.948 -0.062,2.344c-0,3.479 0.041,8.667 0.125,15.562l-5.688,0c0.479,-5.458 0.719,-11.489 0.719,-18.093Z M153.75,22.344c0,0.875 -0.042,2.083 -0.125,3.625l-21.469,0.375c0.209,3.041 1.386,5.588 3.532,7.64c2.145,2.052 4.989,3.078 8.531,3.078c3.166,0 6.135,-0.385 8.906,-1.156l-0.531,4.406c-2.042,0.813 -4.99,1.219 -8.844,1.219c-5.417,0 -9.547,-1.479 -12.391,-4.437c-2.843,-2.959 -4.265,-6.563 -4.265,-10.813c-0,-4.541 1.297,-8.453 3.89,-11.734c2.594,-3.281 6.079,-4.922 10.454,-4.922c4.02,-0 7.078,1.187 9.171,3.562c2.094,2.375 3.141,5.428 3.141,9.157Zm-5.219,0.062c0,-5.854 -2.448,-8.781 -7.343,-8.781c-5,-0 -7.948,3.042 -8.844,9.125l16.187,-0.344Z"
            style={aboutStyle}
          />
        </svg>
        <svg
          width="100%"
          height="100%"
          viewBox="0 0 166 46"
          version="1.1"
        >
          <path
            id="about"
            d="M71.563,28.219c-0.001,4.562 -1.303,8.521 -3.907,11.875c-2.604,3.354 -6.166,5.031 -10.687,5.031c-3.834,-0 -6.438,-0.688 -7.813,-2.063l-0.25,0.001l-0.781,1.218l-4.594,0c0.271,-7.187 0.406,-14.958 0.406,-23.312c0,-7.542 -0.343,-14.427 -1.031,-20.656l6.188,-0.313c-0.209,3.583 -0.313,9.26 -0.313,17.031l0.25,0c2.042,-2.354 5.281,-3.531 9.719,-3.531c3.854,0 6.953,1.438 9.297,4.313c2.344,2.875 3.515,6.343 3.515,10.406Zm-5.562,0.75c-0,-3.146 -0.823,-5.802 -2.469,-7.969c-1.646,-2.167 -3.916,-3.25 -6.812,-3.25c-3.75,0 -6.438,1.135 -8.063,3.406c0,7.417 0.167,13.427 0.5,18.032c1.688,1.416 3.886,2.125 6.594,2.125c3.417,-0 5.979,-1.198 7.687,-3.594c1.709,-2.396 2.563,-5.313 2.563,-8.75Z 
          M38.75,44.281l-6.594,0c0,-1.396 -1.312,-5.781 -3.937,-13.156l-18.032,0c-2.583,7.271 -3.875,11.656 -3.875,13.156l-6.312,0c-0,-0.771 2.687,-7.432 8.062,-19.984c5.375,-12.552 8.063,-19.453 8.063,-20.703l7.25,-0c-0,1.229 2.562,8.031 7.687,20.406c5.125,12.375 7.688,19.135 7.688,20.281Zm-11.969,-17.25c-4.896,-12.229 -7.344,-18.729 -7.344,-19.5l-0.343,0c-0,0.646 -2.532,7.146 -7.594,19.5l15.281,0Z 
          M107.313,28.531c-0.001,5.334 -1.532,9.495 -4.594,12.485c-3.063,2.989 -6.667,4.484 -10.813,4.484c-3.875,-0 -7.203,-1.323 -9.984,-3.969c-2.781,-2.646 -4.172,-6.375 -4.172,-11.187c-0,-5.375 1.536,-9.573 4.609,-12.594c3.073,-3.021 6.683,-4.531 10.828,-4.531c3.875,-0 7.198,1.338 9.969,4.015c2.771,2.677 4.156,6.443 4.156,11.297Zm-5.406,1.094c0,-3.25 -0.817,-6.141 -2.453,-8.672c-1.635,-2.531 -3.963,-3.797 -6.984,-3.797c-3,0 -5.308,1.198 -6.922,3.594c-1.615,2.396 -2.422,5.177 -2.422,8.344c-0,3.271 0.818,6.166 2.453,8.687c1.636,2.521 3.974,3.781 7.016,3.781c3,0 5.302,-1.203 6.906,-3.609c1.604,-2.406 2.406,-5.182 2.406,-8.328Z M140.875,44.25l-4.844,0.188c-0.291,-1.167 -0.437,-2.126 -0.437,-2.876l-0.313,0c-2.771,2.334 -6.135,3.5 -10.094,3.5c-3.604,0 -6.223,-0.869 -7.859,-2.609c-1.635,-1.739 -2.453,-5.245 -2.453,-10.516c-0,-0.75 0.021,-1.864 0.062,-3.343c0.042,-1.479 0.063,-2.49 0.063,-3.032c-0,-3.062 -0.177,-6.666 -0.531,-10.812l5.812,-0.219c-0.25,4.021 -0.375,7.459 -0.375,10.313c0,6.562 0.422,10.838 1.266,12.828c0.844,1.989 2.745,2.984 5.703,2.984c3.333,0 6.083,-0.833 8.25,-2.5c0,-11.583 -0.104,-19.385 -0.313,-23.406l5.625,-0.219c-0.166,3.917 -0.25,9.334 -0.25,16.25c0,4.438 0.23,8.927 0.688,13.469Z M165.938,39.969l-0.376,4.062c-1.645,0.604 -3.197,0.906 -4.656,0.907c-3.75,-0.001 -6.312,-0.954 -7.687,-2.86c-1.375,-1.906 -2.063,-5.318 -2.063,-10.234c0,-3.188 0.021,-7.344 0.063,-12.469c-1.167,0 -2.886,0.063 -5.156,0.188l0.187,-4.532c1.979,0.125 3.75,0.188 5.313,0.188c-0,-1.25 0.104,-4.219 0.312,-8.907l4.906,-0.499c-0.354,4.375 -0.531,7.51 -0.531,9.406c2.042,-0 5.042,-0.104 9,-0.313l-0.219,4.656c-3.75,-0.125 -6.76,-0.187 -9.031,-0.187c-0.042,3.146 -0.063,6.688 -0.063,10.625c0,4.292 0.454,7.13 1.36,8.516c0.906,1.385 2.588,2.078 5.047,2.078c0.812,-0 2.01,-0.209 3.593,-0.625Z"
            //   style={aboutStyle}
          />
        </svg>
</div>
              
            
!

CSS

              
                #about {
  visibility: hidden;
}

.mainWrapper {
  width: 500px;
  height: 200px;
}

.menuWrapper {
  display: flex;
}

.menuItem {
  cursor: pointer;
  margin-right: 20px;
  text-decoration: none;
}

.menuItem:hover {
  text-decoration: underline;
}
              
            
!

JS

              
                /*
Try GreenSock's MorphSVGPlugin for free.
 
 - Press the Fork button
 - add your own SVG, JS and HTML
 - have fun.
 
 Learn more about MorphSVGPlugin here: https://greensock.com/morphSVG
 MorphSVGPlugin is a bonus plugin for Shocking Green and Business Green members: https://www.greensock.com/club

*/

const timeline = gsap.timeline();
let selectedMenuItemId = "#home";

const goTo = (id) => {
  console.log(`selectedMenuItemId = ${selectedMenuItemId}`)
  console.log(`going to ${id}`);    
  timeline.clear();
  timeline.to(selectedMenuItemId,  {
    morphSVG: id
  }, 0)
  
  selectedMenuItemId = id;
}



var tl = gsap.timeline({onUpdate:updateSlider, defaults: {duration: 1}}),
    circle = document.getElementById("circle");

tl.to(circle, {morphSVG:"#hippo"}, "+=1")
  .to(circle, {morphSVG:"#star"}, "+=1")
  .to(circle, {morphSVG:"#elephant"}, "+=1")
  .to(circle, {morphSVG:circle}, "+=1");








/* controls */

$("#slider").slider({
  range: false,
  min: 0,
  max: 1,
  step:.001,
  slide: function ( event, ui ) {
    tl.progress( ui.value ).pause();
  },
  stop: function () {
    tl.play();
  }
});	

function updateSlider() {
  $("#slider").slider("value", tl.progress());
} 
              
            
!
999px

Console