【发布时间】:2019-05-12 19:17:17
【问题描述】:
我正在玩 CSS3 动画和 dashoffset。
这是我一直关注的教程:https://jakearchibald.com/2013/animated-line-drawing-svg/
经过一些适配,这个stroke dashoffset动画还是不行:
@keyframes dash {
to {
stroke-dashoffset: 0;
}
}
#currency-chart-path {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear forwards;
}
<svg id="city-total-v2" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
<g id="Chartline"><g><linearGradient id="SVGID_497_" gradientUnits="userSpaceOnUse" x1="441.5522" y1="423.498" x2="606.2432" y2="423.498"><stop offset="0" style="stop-color: rgb(7, 0, 44);"></stop><stop offset="1" style="stop-color: rgb(124, 10, 103);"></stop></linearGradient><path id="currency-chart-path" fill="url(#SVGID_497_)" d="M590.94,410.83c-0.27-0.11-0.56-0.16-0.85-0.14l-18.37,1.11l-18.77-5.92 c-0.64-0.2-1.33-0.06-1.83,0.37l-18.61,15.82l-21.47-8.61c-0.36-0.15-0.76-0.18-1.15-0.09l-23.31,5.27 c-0.23,0.05-0.44,0.14-0.63,0.27l-21.47,14.11l-21.42,4.45c-1.03,0.21-1.69,1.21-1.47,2.23s1.23,1.67,2.26,1.45l21.78-4.52 c0.24-0.05,0.46-0.14,0.67-0.28l21.49-14.13l22.38-5.07l21.99,8.82c0.66,0.27,1.43,0.14,1.97-0.32l18.68-15.89l18.09,5.71 c0.23,0.07,0.46,0.1,0.7,0.09l18.29-1.1l15.67,6.38l0.68-3.8L590.94,410.83z"></path><linearGradient id="SVGID_498_" gradientUnits="userSpaceOnUse" x1="609.0869" y1="418.3574" x2="609.1055" y2="418.3574"><stop offset="0" style="stop-color: rgb(7, 0, 44);"></stop><stop offset="1" style="stop-color: rgb(124, 10, 103);"></stop></linearGradient><polygon fill="url(#SVGID_498_)" points="609.11,418.37 609.09,418.35 609.09,418.35 "></polygon></g></g>
</svg>
Codepen:https://codepen.io/kopax/pen/WLvRxZ
我希望它从左到右绘制。
这是因为fill 属性而失败吗?
【问题讨论】:
-
尝试帮助并复制文章中的路径.. 有趣的是 svg 示例在“SVG 中的路径”标题下方...
-
什么意思?