I am new to SVG animations, I looked in to SNAP SVG and other libraries, but I cannot find a way to achieve my goal.
I have a SVG file (or the SVG is directly integrated in HTML), that contains multiple paths.
I want to show the SVG image, one path at a time, and animate each path like the example at:
To better describe the result I want, please take a look at this image:
This is a svg element that contains 4 paths.
I want to show draw each path using javascript (not CSS), one after another, and animate them like:
From left to right, each point at a time. To obtain something like a hand drawn effect of the image.
Any suggestions is appreciated.
Thank you
2
Answers
As mentioned in the comments, the linked SO Answer is a good starting point. If you want to stagger the drawing a crude, option would be to set the timeout on each path. (you would have to match the delay with the animations speed). I did this here wit the
style
attribute.Here a short Demo:
We can use the dash offset technique with Snap, which animates stroke-dashoffset. Example, including using prototypes with Snap is below, it will also allow chaining of animations.
You can use an existing element rather than the string example below, using
var element = Snap( someCSSSelector );
You can run below example code below from tutorial site (my original code)