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

Save Automatically?

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

              
                <p>Unfortunately, IE doesn't like using getTotalLength() on polylines. This code has been edited to ignore polylines. <a href="https://codepen.io/jcollette/pen/oJMvzy">Be sure to convert those polylines to just paths</a>! Updated to find path and line within g elements.</p>
<hr>
<p>Use .endSameTime so each element is assigned an offset that will end each individual SVG's animation part at the same time. Lengths: <span id="estlen"></span></p>
<div class="svgcontainer t00">
	<svg class="endSameTime" preserveaspectratio="xMidYMin slice" style="padding-bottom: 86.08%" viewbox="0 0 145.21 125" xmlns="http://www.w3.org/2000/svg">
	<path d="M92.49,112.3a22.53,22.53,0,0,1,0-45.06" fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15"></path>
	<path d="M92.49,67.24a22.53,22.53,0,0,1,0,45.06" fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15"></path>
	<path d="M92.49,112.3a22.53,22.53,0,0,1,0-45.06" fill="none" stroke="#fff200" stroke-linejoin="round" stroke-width="15.5"></path>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="7.5" x2="7.5" y2="125"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="7.5" x2="90.68" y1="20.35" y2="20.35"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="7.5" x2="70.95" y1="48.45" y2="48.45"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="7.5" x2="54.49" y1="76.55" y2="76.55"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="7.5" x2="37.2" y1="104.65" y2="104.65"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="112" x2="141.28" y1="101.03" y2="117.83"></line></svg>
</div>
<div class="svgcontainer t00">
	<svg class="endSameTime" preserveaspectratio="xMidYMin slice" style="padding-bottom: 88.84%" viewbox="0 0 151.95 135" xmlns="http://www.w3.org/2000/svg">
	<path d="M125.67,109.62H25.76A18.28,18.28,0,0,1,7.5,91.36V25.76A18.27,18.27,0,0,1,25.75,7.5H46.09" fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15"></path>
	<path d="M46.09,7.5h80.1a18.29,18.29,0,0,1,18.26,18.26v65.6a18.29,18.29,0,0,1-18.26,18.26h-.52" fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15"></path>
	<path d="M35.81,32.23V86.61" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M90,36.48A22.08,22.08,0,1,1,68,58.56h0A22.08,22.08,0,0,1,90,36.48" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M74.46,43,63.94,32.46" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M105.62,74.14l10.52,10.52" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M105.62,43l10.52-10.52" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M74.46,74.14,63.94,84.66" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M7.5,52.53V25.76A18.27,18.27,0,0,1,25.75,7.5H46.09" fill="none" stroke="#fff200" stroke-linejoin="round" stroke-width="15"></path>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="125.67" x2="125.67" y1="109.62" y2="135"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="26.28" x2="26.28" y1="109.62" y2="135"></line></svg>
</div>
<div class="svgcontainer">
	<svg class="endSameTime" preserveaspectratio="xMidYMin slice" style="padding-bottom: 17.61%" viewbox="0 0 912.92 160.83" xmlns="http://www.w3.org/2000/svg">
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x2="608.62" y1="80.41" y2="80.41"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x2="304.31" y1="40.21" y2="40.21"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x2="912.92" y1="120.62" y2="120.62"></line></svg>
</div>
<p>Use .goSameSpeed so each element is assigned the longest length within the SVG so that the elements animate at the same speed. <span id="gssLen"></span> Longest Lengthes: <span id="longestLen"></span></p>
<div class="svgcontainer t00">
	<svg class="goSameSpeed" preserveaspectratio="xMidYMin slice" style="padding-bottom: 86.08%" viewbox="0 0 145.21 125" xmlns="http://www.w3.org/2000/svg">
	<path d="M92.49,112.3a22.53,22.53,0,0,1,0-45.06" fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15"></path>
	<path d="M92.49,67.24a22.53,22.53,0,0,1,0,45.06" fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15"></path>
	<path d="M92.49,112.3a22.53,22.53,0,0,1,0-45.06" fill="none" stroke="#fff200" stroke-linejoin="round" stroke-width="15.5"></path>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="7.5" x2="7.5" y2="125"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="7.5" x2="90.68" y1="20.35" y2="20.35"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="7.5" x2="70.95" y1="48.45" y2="48.45"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="7.5" x2="54.49" y1="76.55" y2="76.55"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="7.5" x2="37.2" y1="104.65" y2="104.65"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="112" x2="141.28" y1="101.03" y2="117.83"></line></svg>
</div>
<div class="svgcontainer t00">
	<svg class="goSameSpeed" preserveaspectratio="xMidYMin slice" style="padding-bottom: 88.84%" viewbox="0 0 151.95 135" xmlns="http://www.w3.org/2000/svg">
	<path d="M125.67,109.62H25.76A18.28,18.28,0,0,1,7.5,91.36V25.76A18.27,18.27,0,0,1,25.75,7.5H46.09" fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15"></path>
	<path d="M46.09,7.5h80.1a18.29,18.29,0,0,1,18.26,18.26v65.6a18.29,18.29,0,0,1-18.26,18.26h-.52" fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15"></path>
	<path d="M35.81,32.23V86.61" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M90,36.48A22.08,22.08,0,1,1,68,58.56h0A22.08,22.08,0,0,1,90,36.48" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M74.46,43,63.94,32.46" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M105.62,74.14l10.52,10.52" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M105.62,43l10.52-10.52" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M74.46,74.14,63.94,84.66" fill="none" stroke="#19191a" stroke-miterlimit="10" stroke-width="15"></path>
	<path d="M7.5,52.53V25.76A18.27,18.27,0,0,1,25.75,7.5H46.09" fill="none" stroke="#fff200" stroke-linejoin="round" stroke-width="15"></path>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="125.67" x2="125.67" y1="109.62" y2="135"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x1="26.28" x2="26.28" y1="109.62" y2="135"></line></svg>
</div>
<div class="svgcontainer">
	<svg class="goSameSpeed" preserveaspectratio="xMidYMin slice" style="padding-bottom: 17.61%" viewbox="0 0 912.92 160.83" xmlns="http://www.w3.org/2000/svg">
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x2="608.62" y1="80.41" y2="80.41"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x2="304.31" y1="40.21" y2="40.21"></line>
	<line fill="none" stroke="#19191a" stroke-linejoin="round" stroke-width="15" x2="912.92" y1="120.62" y2="120.62"></line></svg>
</div>
              
            
!

CSS

              
                html {
  font-family: sans-serif;
}
svg {
  width: 100%;
  padding-bottom: 50%;
  height: 1px !important;
  height: 0.1px !important;
  overflow: visible;
  box-sizing: content-box;
}
/* svg * {
  transition: stroke-dashoffset 7.5s linear;
} */
.svgcontainer {
  width: 100%;
  position: relative;
  font-size: 1px !important;
  line-height: 1px !important;
  display: inline-block;
}
.svgcontainer.t00 {
  width: 200px;
  max-width: 100%;
  float: left;
}

              
            
!

JS

              
                function dist(x1, x2, y1, y2) {
  return Math.sqrt((x2 -= x1) * x2 + (y2 -= y1) * y2);
}
$("svg.endSameTime")
  .find("path,line")
  .each(function() {
  var target = $(this).get(0);
  if ($(this).is("line")) {
    var len = dist(
      target.x1.baseVal.value,
      target.x2.baseVal.value,
      target.y1.baseVal.value,
      target.y2.baseVal.value
    );
  }
  if ($(this).is("path")) {
    var len = target.getTotalLength();
  }
  len = Math.round(len * 1000) / 1000;
  //output debug code
  $("#estlen").append(len + " ");
  $(this).get(0).style.strokeDasharray = len;
  $(this).get(0).style.strokeDashoffset = len;
});

$("svg.goSameSpeed").each(function() {
  var longestLen = 0;
  var len = 0;
  $(this)
    .find("line,path")
    .each(function() {
      var target = $(this).get(0);
      if ($(this).is("line")) {
        len = dist(
          target.x1.baseVal.value,
          target.x2.baseVal.value,
          target.y1.baseVal.value,
          target.y2.baseVal.value
        );
      }
      if ($(this).is("path")) {
        len = target.getTotalLength();
      }
      len = Math.round(len * 1000) / 1000;
      //output debug code
      $("#gssLen").append(len + " ");
      if (longestLen < len) {
        longestLen = len;
      }
    });
  $("#longestLen").append(longestLen + " "); // output debug code
  $(this)
    .find("line,path")
    .each(function() {
      var target = $(this).get(0);
      $(this).get(0).style.strokeDasharray = longestLen;
      $(this).get(0).style.strokeDashoffset = longestLen;
    });
});

var controller = new ScrollMagic.Controller();

var animateall_Length = 0.5; // length of animation
var animateall_Reverse = true; // play in reverse?
var animateall_OffsetHook = 0.5; // position of hook as percent of vertical screen height
var animateall_Offset = 0; // offset of trigger by px, +down, -up
var animateall_Delay = 0; // seconds of delay to start animation

//
// add individual tweens here as necessary
// Just inputing the class will trigger a "find all and trigger all" effsect -- ideal for individuals
//

var differentTL = new TimelineMax({ repeat: 0, yoyo: true });
differentTL.to(
  "svg *",
  7,
  {
    strokeDashoffset: 0,
    ease: Power0.easeNone
  },
  0
);

var differentScene = new ScrollMagic.Scene({
  triggerElement: "body",
  triggerHook: animateall_OffsetHook,
  offset: -150,
  reverse: animateall_Reverse,
  delay: animateall_Delay
});

differentScene.setTween(differentTL);
differentScene.addTo(controller);
// differentScene.addIndicators(); // This is for debug indicators

              
            
!
999px

Console