Add the segment script (less than 2kb), and define a path
somewhere.
<script src="/dist/segment.min.js"></script>
<svg>
<path id="my-path" ...>
</svg>
Initialize a new Segment
with the path
. Then draw a segment of stroke every time you want with: .draw(begin, end, duration, options)
.
var myPath = document.getElementById("my-path"),
segment = new Segment(myPath);
segment.draw("25%", "75% - 10", 1);
The easing functions used in this demo belong to the excellent library d3-ease.