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

              
                <svg class="morph" width="223px" height="236px" viewBox="0 0 223 236" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
    <g id="Artboard" transform="translate(-379.000000, -248.000000)" fill="#DEABAB">
      <g id="Group" transform="translate(379.000000, 248.000000)">
        <path class="first" d="M51.5405009,1.86148964 C-6.58075151,16.757743 -0.860702599,121.710015 35.6148971,186.223748 C72.0904967,250.73748 202.78487,258.561981 220.603439,173.770091 C238.422009,88.9781997 151.921701,114.881499 124.838915,90.2507054 C97.7561299,65.6199118 109.661753,-13.0347637 51.5405009,1.86148964 Z" id="Path-2"></path>
        <path class="hidden second" d="M49.9979658,34.0898438 C-2.14656543,88.1835938 14.9729125,178.897346 49.9979658,217.515625 C85.0230191,256.133904 85.0230191,203 167.064372,170.589844 C249.105725,138.179688 203.319033,58.7206373 176.236247,34.0898438 C149.153462,9.45905019 102.142497,-20.0039062 49.9979658,34.0898438 Z" id="Path-2-Copy"></path>
        <path class="hidden third" d="M35.0900184,33.936856 C-20.8788038,91.9943427 -4.42908536,189.163491 53.8127645,202.193724 C112.054614,215.223958 188.458263,215.223958 211.245779,178.464278 C234.033295,141.704598 178.786432,82.9867251 149.71739,56.5511023 C120.648347,30.1154796 91.0588407,-24.1206307 35.0900184,33.936856 Z" id="Path-2-Copy-2"></path>
      </g>
    </g>
  </g>
</svg>
<svg class="morph" width="223px" height="236px" viewBox="0 0 223 236" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
    <g id="Artboard" transform="translate(-379.000000, -248.000000)" fill="#DEABAB">
      <g id="Group" transform="translate(379.000000, 248.000000)">
        <path class="first" d="M51.5405009,1.86148964 C-6.58075151,16.757743 -0.860702599,121.710015 35.6148971,186.223748 C72.0904967,250.73748 202.78487,258.561981 220.603439,173.770091 C238.422009,88.9781997 151.921701,114.881499 124.838915,90.2507054 C97.7561299,65.6199118 109.661753,-13.0347637 51.5405009,1.86148964 Z" id="Path-2"></path>
        <path class="hidden second" d="M49.9979658,34.0898438 C-2.14656543,88.1835938 14.9729125,178.897346 49.9979658,217.515625 C85.0230191,256.133904 85.0230191,203 167.064372,170.589844 C249.105725,138.179688 203.319033,58.7206373 176.236247,34.0898438 C149.153462,9.45905019 102.142497,-20.0039062 49.9979658,34.0898438 Z" id="Path-2-Copy"></path>
        <path class="hidden third" d="M35.0900184,33.936856 C-20.8788038,91.9943427 -4.42908536,189.163491 53.8127645,202.193724 C112.054614,215.223958 188.458263,215.223958 211.245779,178.464278 C234.033295,141.704598 178.786432,82.9867251 149.71739,56.5511023 C120.648347,30.1154796 91.0588407,-24.1206307 35.0900184,33.936856 Z" id="Path-2-Copy-2"></path>
      </g>
    </g>
  </g>
</svg>

<div></div>

<svg class="morph" width="223px" height="236px" viewBox="0 0 223 236" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
    <g id="Artboard" transform="translate(-379.000000, -248.000000)" fill="#DEABAB">
      <g id="Group" transform="translate(379.000000, 248.000000)">
        <path class="first" d="M51.5405009,1.86148964 C-6.58075151,16.757743 -0.860702599,121.710015 35.6148971,186.223748 C72.0904967,250.73748 202.78487,258.561981 220.603439,173.770091 C238.422009,88.9781997 151.921701,114.881499 124.838915,90.2507054 C97.7561299,65.6199118 109.661753,-13.0347637 51.5405009,1.86148964 Z" id="Path-2"></path>
        <path class="hidden second" d="M49.9979658,34.0898438 C-2.14656543,88.1835938 14.9729125,178.897346 49.9979658,217.515625 C85.0230191,256.133904 85.0230191,203 167.064372,170.589844 C249.105725,138.179688 203.319033,58.7206373 176.236247,34.0898438 C149.153462,9.45905019 102.142497,-20.0039062 49.9979658,34.0898438 Z" id="Path-2-Copy"></path>
        <path class="hidden third" d="M35.0900184,33.936856 C-20.8788038,91.9943427 -4.42908536,189.163491 53.8127645,202.193724 C112.054614,215.223958 188.458263,215.223958 211.245779,178.464278 C234.033295,141.704598 178.786432,82.9867251 149.71739,56.5511023 C120.648347,30.1154796 91.0588407,-24.1206307 35.0900184,33.936856 Z" id="Path-2-Copy-2"></path>
      </g>
    </g>
  </g>
</svg>
<svg class="morph" width="223px" height="236px" viewBox="0 0 223 236" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
    <g id="Artboard" transform="translate(-379.000000, -248.000000)" fill="#DEABAB">
      <g id="Group" transform="translate(379.000000, 248.000000)">
        <path class="first" d="M51.5405009,1.86148964 C-6.58075151,16.757743 -0.860702599,121.710015 35.6148971,186.223748 C72.0904967,250.73748 202.78487,258.561981 220.603439,173.770091 C238.422009,88.9781997 151.921701,114.881499 124.838915,90.2507054 C97.7561299,65.6199118 109.661753,-13.0347637 51.5405009,1.86148964 Z" id="Path-2"></path>
        <path class="hidden second" d="M49.9979658,34.0898438 C-2.14656543,88.1835938 14.9729125,178.897346 49.9979658,217.515625 C85.0230191,256.133904 85.0230191,203 167.064372,170.589844 C249.105725,138.179688 203.319033,58.7206373 176.236247,34.0898438 C149.153462,9.45905019 102.142497,-20.0039062 49.9979658,34.0898438 Z" id="Path-2-Copy"></path>
        <path class="hidden third" d="M35.0900184,33.936856 C-20.8788038,91.9943427 -4.42908536,189.163491 53.8127645,202.193724 C112.054614,215.223958 188.458263,215.223958 211.245779,178.464278 C234.033295,141.704598 178.786432,82.9867251 149.71739,56.5511023 C120.648347,30.1154796 91.0588407,-24.1206307 35.0900184,33.936856 Z" id="Path-2-Copy-2"></path>
      </g>
    </g>
  </g>
</svg>

<div></div>
              
            
!

CSS

              
                body {
  margin: 10vh auto;
  width: 75vw;
}
div {
  height: 100vh;
}
.hidden {
  display: none;
}
              
            
!

JS

              
                // ============================================================================
// SHAPE MORPHING
// ============================================================================
const loopObs = {
  threshold: 0
};

// SPIN OBSERVER
const spinCallback = function (entries, observer) {
  entries.forEach(function(entry) {
    if (entry.isIntersecting) {
      entry.target.timeline.play();
    } else {
      entry.target.timeline.pause();
    }
  });
};
const morphObserver = new IntersectionObserver(spinCallback, loopObs);

// Animation logic for infinite loop items
const shapesTimeline = document.querySelectorAll(".morph");
shapesTimeline.forEach(function(shape) {
  let tl = gsap.timeline({repeat: -1});
  tl.to(shape.querySelector(".first"), { keyframes: [
    {morphSVG: shape.querySelector(".second")},
    {morphSVG: shape.querySelector(".third")},
    {morphSVG: shape.querySelector(".first")}
  ], duration: 8 })

  shape.timeline = tl;
});
// RUN OBSERVER
shapesTimeline.forEach(el => morphObserver.observe(el));
              
            
!
999px

Console