【发布时间】:2020-12-10 17:40:49
【问题描述】:
我正在尝试创建一个箭头,其箭头从起点移动并在其目标处结束。使用@Robert Longson 的提示成功移动了箭头。我希望轴的末端也跟随箭头并长到它的全长。下面给出了代码,请注意轴没有随着箭头增长,并且也以部分长度结束。有没有办法纠正这个问题。任何帮助将不胜感激。
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="5 0 100 45">
<style>
.wire {
fill: none;
stroke: red;
stroke-width: 1px;
/* Stroke-dasharray property to animate */
stroke-dasharray: 100%;
stroke-dashoffset: 100%;
animation: move linear 5s;
}
@keyframes move {
100% {
stroke-dashoffset: 0;
}
}
</style>
<path d="M10,10 C15,50 95,50 100,10" stroke="blue" stroke-width="2" id="wire" class="wire">
<animate>
<mpath xlink:href="#wire" />
</animate>
</path>
<!-- acceptable movement along the path but incorrect orientation -->
<polygon points="-5,-5 5,0 -5,5 -3,0" fill="red">
<animateMotion dur="5s" repeatCount="1" rotate="auto" fill="freeze">
<mpath xlink:href="#wire" />
</animateMotion>
</polygon>
</svg>
【问题讨论】:
标签: animation svg bezier curve arrows