SVG Image Animation - Auto Drawing

1

I created a vector in Illustrator and saved it in .svg - this is the present and future of the images.

And I got the code in svg of the image and put it on the site. I want to make an animation with this image, an animation like in this example:

link

Where the image already exists, but it is drawn whereas I make a scroll on the page. I already have skrollr.js in my code, use in other objects. But in this case svg I'm not getting it.

It does not have to be this plugin, I'm only interested in the effect of drawing being done gradually instead of appearing the image completely.

If you can not understand it very well, I'll explain it in a better way.

I can almost do the self drawing, however, at some point in the animation, the drawing goes back. The animation makes the outline, but when it finishes the outline returns. I did not catch the business morning yet. SVG is something new to me.

svg{
    display: block;
    vertical-align: bottom;
    height: auto;
    width: 100%;
    .path {
        fill-opacity: 0;
        stroke: #133754;
        fill: #133754;
        stroke-width: 1;
        stroke-dasharray: 0 1014;
        stroke-dashoffset: 1014;
        animation: draw 10s forwards linear;
    }
}

@keyframes draw {
    98%{
        stroke-dashoffset: 0; 
        stroke-dasharray: 1014 0;
        fill-opacity: 0;
    }
    100%{
        fill-opacity: 1;
    }
}

I did it differently now. I updated the above code according to some that I saw on the internet, however, I do not understand its syntax.

stroke-dashoffset: 0;
stroke-dasharray: 1014 0;

I do not know what the values mean.

    
asked by anonymous 18.09.2015 / 15:16

1 answer

1

So Zoom, stroke-dasharray is used to create traits in svg. The stroke-dashoffset controls the size of this stroke, enabling line. Note that in the example you showed, the stroke-dashoffset starts with the value of 6000, identical to the stroke dasharray value. As you scroll the page the script reduces the stroke-dashoffset value to zero by displaying the row. This is how you should animate.

    
29.03.2016 / 22:34