I am trying to animate both a path and a polygon in an SVG arrow along the same path. Currently, I have successfully animated the path using CSS, but I am struggling to figure out how to move the polygon along the path at the same pace.
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 242.66 397" width="242.66" height="397">
<style>.cls-1{fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:bevel;stroke-width:4px;}</style>
<path class="cls-1" d="M240.66,2C11.72,114.98-26.67,239.75,19.39,392.85"/>
<polygon points="0 384.74 2.04 381.29 19 391.37 27.81 373.72 31.39 375.51 20.65 397 0 384.74"/>
</svg>
I have already applied animation to the path with successful results using the following CSS code:
path {
stroke: #000000;
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 4s linear forwards;
}
@keyframes dash {
to {
stroke-dashoffset: 0;
}
}
However, I have attempted to animate the polygon using the code below, but it is not working as expected:
polygon {
offset-distance: 0%;
offset-path: path('M240.66,2C11.72,114.98-26.67,239.75,19.39,392.85');
animation: move 2.1s linear forwards infinite;
}
@keyframes move {
100% {
offset-distance: 100%;
}
}
If anyone can provide insight on how to properly animate the polygon along the same path as the path element, it would be greatly appreciated!