我想了解如何制作这样的动画:
我有这段SVG代码(x1、x2、y1、y2是动态分配的):
<svg id={props.id} class="connect" width="100%" height="100%" viewBox="100%">
<line lass="path_in" x1={x1} y1={y1} x2={x2} y2={y2} stroke="#5184AF" stroke-width="5" stroke-linecap="round" stroke-dasharray="1, 10"/>
</svg>
我尝试了这个:
svg .path_in {
stroke-dasharray: 1300;
animation: dash 4s linear;
-webkit-animation: dash 4s linear;
}
@keyframes dash {
from {
stroke-dashoffset: 1300;
}
to {
stroke-dashoffset: 0;
}
}
@-webkit-keyframes dash {
from {
stroke-dashoffset: 1300;
}
to {
stroke-dashoffset: 0;
}
}