V
V
virtualhero2017-05-12 21:58:37
SVG
virtualhero, 2017-05-12 21:58:37

SVG: how to calculate stroke-dasharray and stroke-dashoffset for stroke animation?

I can't figure out how to correctly calculate the exact number in the stroke-dashoffset and stroke-dasharray properties.
For example, here are simple svg animations: codepen.io/kyledws/pen/Gvelt
Here the .outer class in the stroke-dasharray property has the value 534, if you change it as a percentage or to another number, then there will not be that effect. That is, I don’t understand how I can calculate the exact number that is needed to animate the filling of the stroke from beginning to end, it’s only possible to calculate by hand, but for me it’s stupid. I can’t bang 100%, because the stroke will be filled in different ways, in general, some kind of tin (((

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
call007, 2017-07-12
@call007

It might help...

var path = document.querySelector('.squiggle-container path');
console.log(path.getTotalLength());

Link to proof

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question