css - Start and end of stroke animation -


enter image description herethe stroke-dasharray animation start , end states

what want in green , have in red in image. , want done in css animation. edge of triangle (start , end of stroke) should angled in picture.

my far code :

.path {    stroke-dasharray: 504;    animation: dash 2.5s linear infinite;    -webkit-animation: dash 2.5s linear infinite;    -moz-animation: dash 2.5s linear infinite;    -ms-animation: dash 2.5s linear infinite -o-animation: dash 2.5s linear infinite;  }  @keyframes dash {    0% {      stroke-dashoffset: 0;      stroke-width: 30;    }    50% {      stroke-dashoffset: 500;      stroke-width: 30;    }    100% {      stroke-dashoffset: 1000;      stroke-width: 30;    }  }  div svg {    width: 20%;  }
<div>    <svg version="1.1" id="layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewbox="0 0 252.7 251.9" style="enable-background:new 0 0 252.7 251.9;" xml:space="preserve">      <style type="text/css">        .st0 {          fill: #fff;        }      </style>      <g>        <path stroke="#c5c5c5" stroke-width="20" stroke-linejoin="square" stroke-linecap="butt" class="path" d="m151 45 l79 200 l213 200 l152.324 50 l156 45" fill="url(#fagl)" />      </g>    </svg>  </div>

the issue facing way stoke end rendered. not aware of way make end exaclty @ angle need. none of stoke-linecap values fit.
you should note path element in svg doesn't have same start , end points.

workaround:

a way make path go further need , hide overflow clippath. way, sroke end @ desired angle:

.path {    stroke-dasharray: 23;    animation: dash 2.5s linear infinite;  }  @keyframes dash {    { stroke-dashoffset: -46; }  }  svg { width: 20%; }
<svg viewbox="0 0 10 10">    <clippath id="clip">      <path d="m5 1 l8 9 h2z" />    </clippath>    <path stroke="#c5c5c5" stroke-width="2" class="path" d="m5 1 l8 9 h2 l5 1" fill="url(#fagl)" clip-path="url(#clip)" />  </svg>

note simplified svg , css


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -