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="container container0">
<svg xmlns="http://www.w3.org/2000/svg" width="170px" height="170px" viewBox="0 0 170 170" class="svg inlined-svg" id="svg-0">
  <path fill="#FFF" d="M85 170c-46.87 0-85-38.13-85-85S38.13 0 85 0s85 38.13 85 85-38.13 85-85 85z" id="Circle"/>
  <g id="Icons" fill="#282D33">
    <path d="M84.062 133.923l-35.36-20.417V85.69h4v25.507l31.36 18.107 31.365-18.107V85.69h4v27.816z"/>
    <path d="M82.063 86.586h4v42.273h-4z"/>
    <path d="M99.71 98.102l-19.65-11.35 39.002-22.493 19.655 11.344L99.71 98.102zM88.063 86.755l11.65 6.73 31-17.88-11.652-6.727-30.996 17.877z"/>
    <path d="M68.414 98.102l-39-22.496L49.06 64.26l39.006 22.493-19.652 11.35zm-31-22.498l30.998 17.88 11.652-6.73-31-17.877-11.65 6.727z"/>
    <path d="M49.062 68.834l-19.65-11.347L68.415 34.99l19.652 11.35-39.005 22.494zM37.415 57.49l11.65 6.726 30.998-17.88-11.65-6.726-30.998 17.88z"/>
    <path d="M119.062 68.834L80.06 46.34l19.65-11.35 39.007 22.496-19.655 11.346zm-31-22.497l31 17.88 11.65-6.728-31-17.88-11.65 6.725z"/>
  </g>
  </svg>
</div>
<div class="container container1">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 170 170" class="svg inlined-svg" role="img" id="svg-1" enable-background="new 0 0 170 170" xml:space="preserve">
    <g id="Background"/>
  <g id="Circle">
    <path fill="#FFFFFF" d="M85 170c-46.87 0-85-38.13-85-85S38.13 0 85 0s85 38.13 85 85S131.87 170 85 170z"/>
  </g>
  <g id="TEXT"/>
  <g id="Icons">
    <path fill="none" stroke="#282D33" stroke-width="4" stroke-dasharray="4.03" d="M87.65 131.3c-26.93 0-48.74-21.82-48.74-48.73 0-26.9 21.82-48.69 48.75-48.69 26.92 0 48.69 21.8 48.69 48.69C136.34 109.48 114.56 131.3 87.65 131.3z"/>
    <path fill="none" stroke="#282D33" stroke-width="4" d="M79.06 74.55c0 4.35-3.52 7.88-7.88 7.88l0 0c-4.35 0-7.87-3.53-7.87-7.88V63.81c0-4.35 3.52-7.88 7.88-7.88l0 0c4.36 0 7.88 3.53 7.88 7.88V74.55z"/>
    <path fill="none" stroke="#282D33" stroke-width="4" d="M111.94 101.37c0 4.35-3.52 7.88-7.88 7.88l0 0c-4.35 0-7.88-3.53-7.88-7.88V90.62c0-4.35 3.53-7.88 7.88-7.88l0 0c4.36 0 7.88 3.53 7.88 7.88V101.37z"/>
    <polyline fill="none" stroke="#282D33" stroke-width="4" points="114.6 71.16 114.6 55.6 99.04 55.6 "/>
    <line fill="none" stroke="#282D33" stroke-width="4" x1="114.38" y1="55.83" x2="60.63" y2="109.58"/>
  </g>
  </svg>
</div>

 <div class="container container2">
 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 170 170" class="svg inlined-svg" role="img" id="svg-2" enable-background="new 0 0 170 170" xml:space="preserve">
   <g id="Background">
  </g>
  <g id="Circle">
    <g>
      <path fill="#FFFFFF" d="M85,170c-46.869,0-85-38.131-85-85S38.131,0,85,0s85,38.13,85,85S131.869,170,85,170z"/>
    </g>
  </g>
  <g id="TEXT">
  </g>
    <g id="Icons">
      <g>
        <polyline fill="none" stroke="#282D33" stroke-width="4" points="50.738,74.674 83.593,56.555 116.449,74.674"/>
        <rect x="36.992" y="74.523" fill="none" stroke="#282D33" stroke-width="4" width="93.203" height="7.641"/>
        <g>
          <rect x="36.992" y="119.123" fill="none" stroke="#282D33" stroke-width="4" width="22.203" height="12.037"/>
          <rect x="107.992" y="119.123" fill="none" stroke="#282D33" stroke-width="4" width="22.203" height="12.037"/>
        </g>
        <g>
          <line fill="none" stroke="#282D33" stroke-width="4" x1="107.672" y1="128.432" x2="59.514" y2="128.432"/>
        </g>
        <g>
          <line fill="none" stroke="#282D33" stroke-width="4" x1="107.672" y1="121.432" x2="59.514" y2="121.432"/>
        </g>
        <polygon fill="none" stroke="#282D33" stroke-width="4" stroke-linejoin="bevel" points="83.592,46.487 132.524,74.529 83.592,74.529 34.662,74.529"/>
        <line fill="none" stroke="#282D33" stroke-width="4" x1="83.593" y1="46.194" x2="83.593" y2="35.194"/>
        <g>
          <polygon fill="none" stroke="#282D33" stroke-width="4" points="83.593,41.861 83.593,37.121 83.593,32.381 98.16,32.381 96.056,37.121 98.16,41.861"/>
        </g>
        <g>
          <g>
            <line fill="none" stroke="#282D33" stroke-width="4" x1="43.468" y1="86.998" x2="43.468" y2="114.247"/>
            <line fill="none" stroke="#282D33" stroke-width="4" x1="51.468" y1="86.998" x2="51.468" y2="114.247"/>
          </g>
          <g>
            <line fill="none" stroke="#282D33" stroke-width="4" x1="67.552" y1="86.998" x2="67.552" y2="114.247"/>
            <line fill="none" stroke="#282D33" stroke-width="4" x1="75.552" y1="86.998" x2="75.552" y2="114.247"/>
          </g>
          <g>
            <line fill="none" stroke="#282D33" stroke-width="4" x1="91.635" y1="86.998" x2="91.635" y2="114.247"/>
            <line fill="none" stroke="#282D33" stroke-width="4" x1="99.635" y1="86.998" x2="99.635" y2="114.247"/>
          </g>
          <g>
            <line fill="none" stroke="#282D33" stroke-width="4" x1="115.718" y1="86.998" x2="115.718" y2="114.247"/>
            <line fill="none" stroke="#282D33" stroke-width="4" x1="123.718" y1="86.998" x2="123.718" y2="114.247"/>
          </g>
        </g>
      </g>
    </g>
  </svg>
</div>

<div class="container container3">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 170 170" class="svg inlined-svg" role="img" id="svg-3" enable-background="new 0 0 170 170" xml:space="preserve">
    <g id="Background"/>
    <g id="Circle">
      <path fill="#FFFFFF" d="M85 170c-46.87 0-85-38.13-85-85S38.13 0 85 0s85 38.13 85 85S131.87 170 85 170z"/>
    </g>
    <g id="TEXT"/>
    <g id="Icons">
      <polyline fill="none" stroke="#282D33" stroke-width="4" points="50.74 74.67 83.59 56.56 116.45 74.67"/>
      <rect x="36.99" y="74.52" fill="none" stroke="#282D33" stroke-width="4" width="93.2" height="7.64"/>
      <rect x="36.99" y="119.12" fill="none" stroke="#282D33" stroke-width="4" width="22.2" height="12.04"/>
      <rect x="107.99" y="119.12" fill="none" stroke="#282D33" stroke-width="4" width="22.2" height="12.04"/>
      <line fill="none" stroke="#282D33" stroke-width="4" x1="107.67" y1="128.43" x2="59.51" y2="128.43"/>
      <line fill="none" stroke="#282D33" stroke-width="4" x1="107.67" y1="121.43" x2="59.51" y2="121.43"/>
      <polygon fill="none" stroke="#282D33" stroke-width="4" stroke-linejoin="bevel" points="83.59 46.49 132.52 74.53 83.59 74.53 34.66 74.53"/>
      <line fill="none" stroke="#282D33" stroke-width="4" x1="83.59" y1="46.19" x2="83.59" y2="35.19"/>
      <polygon fill="none" stroke="#282D33" stroke-width="4" points="83.59 41.86 83.59 37.12 83.59 32.38 98.16 32.38 96.06 37.12 98.16 41.86"/>
      <line fill="none" stroke="#282D33" stroke-width="4" x1="43.47" y1="87" x2="43.47" y2="114.25"/>
      <line fill="none" stroke="#282D33" stroke-width="4" x1="51.47" y1="87" x2="51.47" y2="114.25"/>
      <line fill="none" stroke="#282D33" stroke-width="4" x1="67.55" y1="87" x2="67.55" y2="114.25"/>
      <line fill="none" stroke="#282D33" stroke-width="4" x1="75.55" y1="87" x2="75.55" y2="114.25"/>
      <line fill="none" stroke="#282D33" stroke-width="4" x1="91.64" y1="87" x2="91.64" y2="114.25"/>
      <line fill="none" stroke="#282D33" stroke-width="4" x1="99.64" y1="87" x2="99.64" y2="114.25"/>
      <line fill="none" stroke="#282D33" stroke-width="4" x1="115.72" y1="87" x2="115.72" y2="114.25"/>
      <line fill="none" stroke="#282D33" stroke-width="4" x1="123.72" y1="87" x2="123.72" y2="114.25"/>
    </g>
  </svg>
</div>

<div class="button-holder">
  <button class="run0">Run 1st SVG</button>
  <button class="run1">Run 2nd SVG</button>
  <button class="run2">Run 3rd SVG</button>
  <button class="run3">Run 3rd SVG Optimized</button>
</div>

              
            
!

CSS

              
                .svg.inlined-svg {
  visibility: hidden;
}

html {
  background: #000;
}

.container {
  width: 170px;
  height: 170px;
  position: absolute;
  left: 0;
  top: 0;
}

svg {
  width: 100%;
}

.container.top {
  z-index: 1000;
}

.button-holder { 
  width: 100%;
  position: fixed; 
  bottom: 10px; 
  text-align: center; }
button {
  cursor: pointer;
  border: none;
  padding: 7px 10px;
  font-size: 14px;
  background: blue;
  display: inline-block;
  margin-right: 10px;
  color: white;
  font-weight: bold;
}
button:hover {
  background: lightblue;
  color: #222222;
}

              
            
!

JS

              
                function getShapes(svgID) {
  var shapes = [];
  
  // now parse through the SVG to see what types of shapes are present and create an array of elements
  for ( var s=0; s<shapePossibilites.length; s++ ) {
    var shape = shapePossibilites[s];
    if ( $("svg#"+svgID + " " + shape).length ) {
      shapes.push($("svg#"+svgID + " " + shape));
    }
  }
  return shapes;
}

function animateLines(svgID) {
  if(svgID == null || svgID == undefined) { return; }
  var shapes = getShapes(svgID);
  return TweenMax.fromTo(shapes, 1, {drawSVG:0}, {drawSVG:"102%"}, "-=1"); // draw the lines
}

function unHideSVG(svgID) {
  return TweenMax.set($("#"+svgID), {visibility:"visible"});
}

function rotate(svgID,amount) {
  if(svgID == null || svgID == undefined) { return; }
  return TweenMax.to($("#"+svgID), 1, {rotation:amount, ease:Bounce.easeOut});
}

function hideStrokes(shapes) {
  // shapes string contains the svg id so is specific to svg
  return TweenMax.set(shapes, {drawSVG:0});
}

function inFromCoords(containerDiv, coords) {
  return TweenMax.fromTo(containerDiv, 1, {x: coords.fromX, y: coords.fromY}, {x: coords.toX, y: coords.toY, ease: Bounce.easeOut});
}

function inAnimation(containerDiv,fromObj,toObj) {
  // return TweenMax.fromTo(containerDiv, 1, {left: 0, top: 0}, {left: "50%", xPercent: -50, top: "50%", yPercent:-50, ease: Power3.easeInOut});
  return TweenMax.fromTo(containerDiv, 1, fromObj, toObj);
}

function slideInAndDraw(containerDiv,coords)
{
  var svgID = containerDiv.find("svg").attr('id');
  var shapes = getShapes(svgID);
  main.clear();
  $('.container').removeClass('top');
  containerDiv.addClass('top');
  
  main.add(unHideSVG(svgID)) // un-hide the svg
      .add(hideStrokes(shapes)) //hide the stroke
      // .add(inFromCoords(containerDiv,coords))
      .add(inAnimation(containerDiv,coords.fromObj,coords.toObj))
      .add(animateLines(svgID))
      .add(rotate(svgID,-360));
}

var uniqueIDs = [],
    main = new TimelineMax(),
    shapePossibilites = ["rect", "circle", "ellipse", "polyline", "polygon", "path", "line"]; // you can add whatever you want to this array;
$('button').click(function(){
  // main.clear();
});

$('button.run0').click(function(){
  var coords = {
    fromObj: {left: 0, top: 0},
    toObj: {left: "50%", xPercent: -50, top: "80%", yPercent:-80, ease: Power3.easeInOut}
  };
  slideInAndDraw($('.container0'),coords);
});

$('button.run1').click(function(){
  var coords = {
    fromObj: {left: "100%", top: "100%"},
    toObj: {left: "60%", xPercent: -60, top: "50%", yPercent:-50, ease: Power3.easeInOut}
  };
  slideInAndDraw($('.container1'),coords);
});

$('button.run2').click(function(){
  var coords = {
    fromObj: {left: 0, top: "100%"},
    toObj: {left: "40%", xPercent: -40, top: "50%", yPercent:-50, ease: Power3.easeInOut}
  };
  slideInAndDraw($('.container2'),coords);
});

$('button.run3').click(function(){
  var coords = {
    fromObj: {left: "50%", xPercent: -50, top: "40%", yPercent:-40, scale: 0},
    toObj: {left: "50%", xPercent: -50, top: "20%", yPercent:-20, scale: 1.0, ease: Bounce.easeOut}
  };
  slideInAndDraw($('.container3'),coords);
});

              
            
!
999px

Console