SVG straight line animation CSS - html

I am trying to achieve this (the picture below) in using SVG path for animation in a website. I saw this https://css-tricks.com/svg-line-animation-works/ and wanted to try it. But i am not sure how do i create the path out and the animation. Please do help me! Thanks

You can use svg code for animation. You can use CSS animation on svg paths.
.st0{
fill:none;
stroke:#000000;
stroke-miterlimit:10;
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
-webkit-animation: draw1 4s linear forwards;
animation: draw1 4s linear forwards;
}
.st1{
fill:none;
stroke:#000000;
stroke-miterlimit:10;
stroke-dasharray: 200;
stroke-dashoffset: 200;
-webkit-animation: draw2 3s linear 2s forwards;
animation: draw2 3s linear 2s forwards;
}
#-webkit-keyframes draw1{
to {stroke-dashoffset: 0;}
}
#keyframes draw1{
to {stroke-dashoffset: 0;}
}
#-webkit-keyframes draw2{
to {stroke-dashoffset: 0;}
}
#keyframes draw2{
to {stroke-dashoffset: 0;}
}
<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 614 53" style="enable-background:new 0 0 614 53;" xml:space="preserve">
<polyline class="st0" points="0.5,53 0.5,20.7 613.5,20.7 613.5,53 "/>
<line class="st1" x1="307" y1="53" x2="307" y2="0"/>
</svg>

SVG solution
The animation uses the attribute <stroke-dashoffset> - the indent from the beginning of the line. At the maximum value of <stroke-dashoffset> the visible line is zero.
With the value of <stroke-dashoffset ="0"> the line acquires the maximum size.
It is necessary to accurately calculate the length of the line to avoid unpredictable effects in the animation.
In this example, the length of <line> is 53px, for <polyline> is 680px.
<style>
.st0{fill:none;stroke:#000000;stroke-miterlimit:10; stroke-dasharray: 680; stroke-dashoffset: 680;}
.st1{fill:none;stroke:#000000;stroke-miterlimit:10; stroke-dasharray: 53; stroke-dashoffset: 53;}
</style>
<svg version="1.1" viewBox="0 0 614 53" >
<polyline class="st0" points="0.5,53 0.5,20.7 613.5,20.7 613.5,53 " >
<animate
attributeName="stroke-dashoffset"
from="680"
to="0"
dur="2s"
fill="freeze" />
</polyline>
<line class="st1" x1="307" y1="53" x2="307" y2="0">
<animate
attributeName="stroke-dashoffset"
from="53"
to="0"
dur="2s"
fill="freeze" />
</line>
</svg>

Related

HTML SVG reduce circle size

I have found animated circle made with svg but I need to reduce the circle size
How can I modify the code please?
#keyframes dash {
from {
stroke-dashoffset: 816;
}
to {
stroke-dashoffset: 0;
}
}
.progress-circle path {
stroke-dasharray: 816;
stroke-dashoffset: 0;
animation: dash 2s linear;
animation-delay: 0.3s;
}
<svg class="progress-circle" width="70" height="70">
<path
d="m35,2.5c17.955803,0 32.5,14.544199 32.5,32.5c0,17.955803 -14.544197,32.5 -32.5,32.5c-17.955803,0 -32.5,-14.544197 -32.5,-32.5c0,-17.955801 14.544197,-32.5 32.5,-32.5z"
stroke="#000" stroke-width="1" fill="transparent" />
</svg>
You need to change the width and height and then add the viewbox atrribute with the original size:
#keyframes dash {
from {
stroke-dashoffset: 816;
}
to {
stroke-dashoffset: 0;
}
}
.progress-circle path {
stroke-dasharray: 816;
stroke-dashoffset: 0;
animation: dash 2s linear;
animation-delay: 0.3s;
}
<svg class="progress-circle" width="30" height="30" viewBox="0 0 70 70">
<path
d="m35,2.5c17.955803,0 32.5,14.544199 32.5,32.5c0,17.955803 -14.544197,32.5 -32.5,32.5c-17.955803,0 -32.5,-14.544197 -32.5,-32.5c0,-17.955801 14.544197,-32.5 32.5,-32.5z"
stroke="#000" stroke-width="1" fill="transparent" />
</svg>
add viewBox= "0 0 50 50" in svg tag and reduce svgwidth and height

A JQuery function for SVG, to execute 2nd animation as soon as, 1st animation completes?

I applied the animation-delay technique, but to achieve a the handwriting effect animation, I had to cut the object wherever it intersects, and drew a path and converted it to a clipping mask, e.g. letter "W" divided into 4 parts and drew different paths for different part for the said above, and animating it, to give a clean handwriting effect, giving path a stroke width, It took me a lot more time as the font was too complicated.
Currently I am achieving the said animation using animation-delay, CSS function.
CSS Code
#W2-Path {
animation-delay: .5s
}
#W3-Path {
animation-delay: 1s
}
#W4-Path {
animation-delay: 1.5s
}
#O-Path {
animation-delay: 2s
}
#R1-Path-2 {
animation-delay: 3.5s
}
#R2-Path-2 {
animation-delay: 4s
}
#R3-Path-2 {
animation-delay: 4.5s
}
#L1-Path-2 {
animation-delay: 5s
}
#L2-Path-2 {
animation-delay: 5.5s
}
#L3-Path-2 {
animation-delay: 6s
}
#D1-Path {
animation-delay: 6.5s
}
#D2-Path {
animation-delay: 7s
}
I was thinking if there is any other way through which I can start the 2nd animation as the 1st animation completes, and it just keeps going on giving the animation more smoother effect and perfect timing, implementing JQuery?
CodePen: https://codepen.io/ToxifiedM/pen/MWKeERr
Original Question: How Can I Make SVG Text Animation Seamless And Accurate?
Linked Question 1: To Control SVG CSS Based Animation Using Jquery?
Linked Question 2: To Control The Speed Of Multiple SVG Elements Using Jquery?
I'm answering only for the latter W
I've changed the svg code you have, because it can be done in a more simple way.
You are wrapping every line in 2 groups. I'm using just the lines. Also you are using style="clip-path: url(#clip-path)" I've transformed this to a presentational attribute like so: clip-path="url(#clip-path)" because in javascript I want to set the animation-delay as inline style for the lines.
An other change: I'm using stroke-dasharray: 8 and stroke-dashoffset: 8 since 8 is the length of the lines for the letter W. I know the length of the lines because I've used the getTotalLength() method.
The stroke and the stroke-width are set only once for the group since the lines for the letter have the same style.
The javascript is selecting all the lines in a group and then is looping through the lines and setting the animation-delay:${i*1}s where i is the nth line. Please observe that the order of the lines in the group is from the first to the 4-th and not vice versa as you have them in your code.
let Wls = document.querySelector("#W").querySelectorAll("line");//all the lines in the W group
Wls.forEach((l,i)=>{
// for each line in the W group
// set the style attribute
l.setAttribute("style", `animation-delay:${i*1}s`)
})
body {
background: white;
}
svg {
width: 90vh;
border:solid;
}
#W line{
stroke-dasharray: 8;
stroke-dashoffset: 8;
animation: letter-animation 1s linear forwards;
}
#keyframes letter-animation {
0% {
stroke-dashoffset: 8;
}
100% {
stroke-dashoffset: 0;
}
}
<svg id="WOYP" viewBox="0 0 9 9">
<defs>
<clipPath id="clip-path-44" transform="translate(-5.561 -10.291)">
<path id="W4" d="M11.676,16.41l.234.578c.236-.631.477-1.261.715-1.891q.222-.6.449-1.188t.409-1.063q.181-.476.308-.8c.084-.214.136-.348.156-.4s.05-.12.066-.16a.594.594,0,0,1,.061-.111.754.754,0,0,1,.086-.1.768.768,0,0,1,.151-.11h-1.03c.121.053.192.117.212.19a.481.481,0,0,1-.04.291c0,.007-.025.079-.076.216s-.118.319-.2.546-.18.483-.287.767-.216.573-.323.867Z" />
</clipPath>
<clipPath id="clip-path-45" transform="translate(-5.561 -10.291)">
<path id="W3" d="M11.675,16.358Zm0,0h0l.011.029h0l.232.575c-.152.4-.311.82-.474,1.252L10.176,15.07q-.242-.6-.478-1.183t-.433-1.058q-.2-.474-.333-.793c-.09-.213-.146-.343-.166-.389a1.8,1.8,0,0,0-.176-.27.774.774,0,0,0-.348-.209h1.833a.3.3,0,0,0-.221.239.9.9,0,0,0,.03.35c0,.006.027.076.08.209s.123.308.207.524.179.464.287.744.218.562.332.848Q11.179,15.089,11.675,16.358Z" />
</clipPath>
<clipPath id="clip-path-46" transform="translate(-5.561 -10.291)">
<path id="W2" d="M9.139,16.411l.234.578c.236-.632.477-1.261.715-1.891q.222-.6.45-1.189t.408-1.062c.122-.318.224-.584.308-.8s.137-.347.157-.4l.065-.16a.556.556,0,0,1,.061-.11.7.7,0,0,1,.086-.1.8.8,0,0,1,.151-.11h-1.03c.121.054.192.117.213.191a.488.488,0,0,1-.041.29c0,.007-.025.079-.076.216s-.117.319-.2.546-.179.483-.287.768-.216.573-.323.867Z" />
</clipPath>
<clipPath id="clip-path-47" transform="translate(-5.561 -10.291)">
<path id="W1" d="M9.138,16.358Zm0,0h0l.012.029h0l.233.575q-.229.6-.475,1.252L7.639,15.07q-.242-.6-.478-1.183t-.433-1.058q-.2-.474-.332-.793l-.166-.389a1.8,1.8,0,0,0-.177-.27.764.764,0,0,0-.347-.209H7.539a.305.305,0,0,0-.222.239.938.938,0,0,0,.03.35c0,.006.027.076.081.209s.122.308.206.524.18.464.287.744.218.562.332.848Q8.642,15.089,9.138,16.358Z" />
</clipPath>
</defs>
<g id="W" stroke="#003668" stroke-width="2">
<line x1="0.93" y1="0.482" x2="3.873" y2="7.937" clip-path="url(#clip-path-47)" />
<line x1="3.088" y1="7.937" x2="5.966" y2="0.482" clip-path="url(#clip-path-46)" />
<line x1="3.481" y1="0.482" x2="6.424" y2="7.937" clip-path="url(#clip-path-45)" />
<line x1="5.639" y1="7.937" x2="8.517" y2="0.482" clip-path="url(#clip-path-44)" />
</g>
</svg>
UPDATE
The OP is commenting:
So when I was actually trying to implement it, I got on the letter "O", its a path not a line, I tried your method, its not appearing for path, what can be done for that any clue?
In this case you'll have to animate the path. This time you don't need a different css animation and since the final value for the stroke-dashoffset is 0 you don't need a different animation. However you'll need to calculate the path's total length to use it for the path's stroke-dasharray and stroke-dashoffse. In this case is 20.4.
let Wls = document.querySelector("#W").querySelectorAll("line")
Wls.forEach((l,i)=>{
l.setAttribute("style", `animation-delay:${i*1}s`)
})
body {
background: white;
}
svg {
width: 90vh;
border:solid;
overflow:visible;
}
#W line{
stroke-dasharray: 8;
stroke-dashoffset: 8;
animation: letter-animation 1s linear forwards;
}
#O path{
stroke-dasharray: 20.4;
stroke-dashoffset: 20.4;
animation: letter-animation 1s linear forwards;
animation-delay:4.5s
}
#keyframes letter-animation {
100% {
stroke-dashoffset: 0;
}
}
#keyframes letter-animation {
100% {
stroke-dashoffset: 0;
}
}
<svg id="WOYP" viewBox="0 0 29 9">
<defs>
<clipPath id="clip-path-44" transform="translate(-5.561 -10.291)">
<path id="W4" d="M11.676,16.41l.234.578c.236-.631.477-1.261.715-1.891q.222-.6.449-1.188t.409-1.063q.181-.476.308-.8c.084-.214.136-.348.156-.4s.05-.12.066-.16a.594.594,0,0,1,.061-.111.754.754,0,0,1,.086-.1.768.768,0,0,1,.151-.11h-1.03c.121.053.192.117.212.19a.481.481,0,0,1-.04.291c0,.007-.025.079-.076.216s-.118.319-.2.546-.18.483-.287.767-.216.573-.323.867Z" />
</clipPath>
<clipPath id="clip-path-45" transform="translate(-5.561 -10.291)">
<path id="W3" d="M11.675,16.358Zm0,0h0l.011.029h0l.232.575c-.152.4-.311.82-.474,1.252L10.176,15.07q-.242-.6-.478-1.183t-.433-1.058q-.2-.474-.333-.793c-.09-.213-.146-.343-.166-.389a1.8,1.8,0,0,0-.176-.27.774.774,0,0,0-.348-.209h1.833a.3.3,0,0,0-.221.239.9.9,0,0,0,.03.35c0,.006.027.076.08.209s.123.308.207.524.179.464.287.744.218.562.332.848Q11.179,15.089,11.675,16.358Z" />
</clipPath>
<clipPath id="clip-path-46" transform="translate(-5.561 -10.291)">
<path id="W2" d="M9.139,16.411l.234.578c.236-.632.477-1.261.715-1.891q.222-.6.45-1.189t.408-1.062c.122-.318.224-.584.308-.8s.137-.347.157-.4l.065-.16a.556.556,0,0,1,.061-.11.7.7,0,0,1,.086-.1.8.8,0,0,1,.151-.11h-1.03c.121.054.192.117.213.191a.488.488,0,0,1-.041.29c0,.007-.025.079-.076.216s-.117.319-.2.546-.179.483-.287.768-.216.573-.323.867Z" />
</clipPath>
<clipPath id="clip-path-47" transform="translate(-5.561 -10.291)">
<path id="W1" d="M9.138,16.358Zm0,0h0l.012.029h0l.233.575q-.229.6-.475,1.252L7.639,15.07q-.242-.6-.478-1.183t-.433-1.058q-.2-.474-.332-.793l-.166-.389a1.8,1.8,0,0,0-.177-.27.764.764,0,0,0-.347-.209H7.539a.305.305,0,0,0-.222.239.938.938,0,0,0,.03.35c0,.006.027.076.081.209s.122.308.206.524.18.464.287.744.218.562.332.848Q8.642,15.089,9.138,16.358Z" />
</clipPath>
<clipPath id="clip-path-43">
<path id="clipO" d="M22.38,14.637v.026h0v.081l0,.023a3.231,3.231,0,0,1-.367,1.385,3.556,3.556,0,0,1-.9,1.089,3.814,3.814,0,0,1-1.2.655,3.724,3.724,0,0,1-1.289.2,3.869,3.869,0,0,1-1.4-.3,3.818,3.818,0,0,1-1.169-.756,3.474,3.474,0,0,1-.791-1.133A3.228,3.228,0,0,1,15,14.763v-.119h0v-.022h0V14.6h0v-.047h0v-.024h0V14.38a3.256,3.256,0,0,1,.273-1.138,3.554,3.554,0,0,1,.756-1.109,3.749,3.749,0,0,1,2.8-1.073,4.05,4.05,0,0,1,1.265.257A3.668,3.668,0,0,1,21.241,12a3.433,3.433,0,0,1,.836,1.113,3.107,3.107,0,0,1,.3,1.237l0,.021v.131h0v.025h0v.025h0v.052h0v.025ZM21.265,14.4a3.982,3.982,0,0,0-.18-1.025,2.913,2.913,0,0,0-.529-.99,2.287,2.287,0,0,0-.821-.628,2.492,2.492,0,0,0-1.043-.218,2.667,2.667,0,0,0-1.038.2,2.42,2.42,0,0,0-.826.569,2.593,2.593,0,0,0-.549.905,3.436,3.436,0,0,0-.2,1.085v.232h0v.024h0V14.6h0v.024h0v.023h0v.025l0,.023v.027a3.52,3.52,0,0,0,.228,1.105,2.93,2.93,0,0,0,.615.98,2.5,2.5,0,0,0,1.778.762,2.549,2.549,0,0,0,1.023-.2,2.313,2.313,0,0,0,.811-.584,2.739,2.739,0,0,0,.534-.915,3.439,3.439,0,0,0,.188-1.021v-.185h0v-.044h0V14.6h0v-.022h0v-.022h0v-.022h0v-.022h0V14.4Z" />
</clipPath>
</defs>
<g id="W" stroke="#003668" stroke-width="2">
<line x1="0.93" y1="0.482" x2="3.873" y2="7.937" clip-path="url(#clip-path-47)" />
<line x1="3.088" y1="7.937" x2="5.966" y2="0.482" clip-path="url(#clip-path-46)" />
<line x1="3.481" y1="0.482" x2="6.424" y2="7.937" clip-path="url(#clip-path-45)" />
<line x1="5.639" y1="7.937" x2="8.517" y2="0.482" clip-path="url(#clip-path-44)" />
</g>
<g id="O" stroke="#003668" stroke-width="2" fill="none">
<path id="OPath" d="M18.657,11.3a3.1,3.1,0,0,0-2.289.981,3.448,3.448,0,0,0-.458,3.858,2.78,2.78,0,0,0,2.747,1.7,2.961,2.961,0,0,0,2.813-1.7,3.514,3.514,0,0,0-.458-3.858A3.055,3.055,0,0,0,18.657,11.3Z" transform="translate(-5.561 -10.291)" clip-path="url(#clip-path-43)" />
</g>
</svg>

Animation delay in SVG not respected

I want to make appear up some currency, this is the code:
#keyframes appearUp {
0% {
opacity: 1;
transform: translate3d(0, 5px, 0);
}
100% {
transform: translate3d(0, -5px, 0);
}
}
#currency-usd,
#currency-euro,
#currency-pound {
opacity: 0;
}
#currency-usd {
animation: appearUp 5s ease-out 0s infinite;
}
#currency-euro {
animation: appearUp 5s ease-out 5s infinite;
}
#currency-pound {
animation: appearUp 5s ease-out 10s infinite;
}
<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="Roundblockcurrency">
<linearGradient id="SVGID_454_" gradientUnits="userSpaceOnUse" x1="379.3599" y1="466.0918" x2="379.3599" y2="508.5988"><stop offset="0" style="stop-color: rgb(124, 10, 103);"></stop><stop offset="1" style="stop-color: rgb(178, 18, 85);"></stop></linearGradient>
<path fill-rule="evenodd" clip-rule="evenodd" fill="url(#SVGID_454_)" d="M352.21,531.89l0-0.05v-61.9 c12.06-11.81,31.17-21.38,54.29-28.16v61.9c-23.13,6.78-42.23,16.35-54.29,28.16L352.21,531.89L352.21,531.89z"></path>
<path id="currency-usd" fill-rule="evenodd" clip-rule="evenodd" fill="#F07A28" d="M397.79,477.91c0,2-0.68,4.13-2.05,6.39
c-1.37,2.26-3.11,4.3-5.24,6.14v2.42c0,0.68-0.23,1.39-0.69,2.14c-0.46,0.75-1.03,1.35-1.72,1.79c-0.66,0.42-1.21,0.55-1.66,0.38
c-0.45-0.16-0.67-0.59-0.67-1.26v-2.18c-1.42,0.78-2.71,1.32-3.88,1.61c-1.17,0.29-2.31,0.32-3.41,0.09
c-0.71-0.17-1.06-0.63-1.06-1.38c0-0.6,0.22-1.27,0.67-2.01c0.45-0.74,0.98-1.32,1.62-1.72c0.5-0.32,0.95-0.46,1.34-0.4
c0.82,0.13,1.59,0.14,2.33,0.04c0.74-0.1,1.54-0.36,2.41-0.79v-7.6c-5.28,2.44-7.92,1.54-7.92-2.72c0-2.16,0.74-4.4,2.21-6.74
c1.47-2.34,3.38-4.42,5.72-6.23v-1.28c0-0.67,0.23-1.39,0.69-2.14c0.46-0.75,1.03-1.35,1.72-1.79c0.66-0.42,1.21-0.55,1.66-0.39
c0.45,0.17,0.67,0.59,0.67,1.26v1.44c2.23-1.05,4.07-1.43,5.52-1.14c0.76,0.1,1.14,0.55,1.14,1.33c0,0.6-0.22,1.27-0.67,2.01
c-0.45,0.74-0.97,1.31-1.58,1.7c-0.39,0.25-0.75,0.37-1.06,0.33c-0.79-0.14-1.91,0.02-3.35,0.48v7.21c2.55-1.05,4.4-1.36,5.56-0.95
C397.21,474.35,397.79,475.68,397.79,477.91L397.79,477.91z M382.49,475.65c0,0.86,0.28,1.37,0.83,1.55
c0.55,0.18,1.37,0.07,2.44-0.31v-6.47c-1.08,0.9-1.89,1.8-2.44,2.71C382.77,474.03,382.49,474.87,382.49,475.65L382.49,475.65z
M390.49,485.76c0.76-0.8,1.38-1.61,1.85-2.42c0.47-0.81,0.71-1.52,0.71-2.11c0-0.73-0.21-1.22-0.63-1.48
c-0.42-0.26-1.06-0.29-1.93-0.1V485.76L390.49,485.76z"/>
<path id="currency-euro" fill="#F07A28" d="M399.44,482.88c0,0.33-0.09,0.69-0.27,1.08c-0.18,0.4-0.42,0.77-0.72,1.11c-0.96,1.18-2.02,2.29-3.19,3.34
s-2.34,1.93-3.52,2.64c-3.02,1.8-5.72,2.57-8.1,2.31s-4.06-1.61-5.02-4.06l-2.3,1.38c-0.58,0.35-1.06,0.46-1.44,0.33
c-0.39-0.13-0.58-0.46-0.58-1.01s0.19-1.11,0.58-1.7c0.38-0.59,0.86-1.05,1.44-1.4l1.6-0.96c-0.03-0.29-0.04-0.76-0.04-1.42v-0.74
l-1.56,0.93c-0.58,0.35-1.06,0.45-1.44,0.33c-0.39-0.13-0.58-0.46-0.58-1.01s0.19-1.12,0.58-1.7c0.38-0.58,0.86-1.05,1.44-1.39
l2.18-1.3c0.55-2.33,1.46-4.64,2.74-6.94c1.28-2.3,2.82-4.41,4.63-6.34s3.77-3.53,5.88-4.79c1.18-0.71,2.34-1.23,3.47-1.56
c1.14-0.34,2.2-0.49,3.19-0.44c0.66-0.04,0.99,0.31,0.99,1.05c0,0.49-0.17,1.04-0.49,1.65c-0.33,0.64-0.78,1.13-1.36,1.47
c-0.38,0.23-0.75,0.35-1.11,0.38c-1.45-0.09-3.02,0.36-4.69,1.36c-2.11,1.26-3.98,2.94-5.61,5.04c-1.63,2.1-2.82,4.34-3.56,6.74
l6.62-3.92c0.58-0.35,1.06-0.45,1.44-0.33c0.38,0.13,0.58,0.45,0.58,0.97c0,0.55-0.19,1.12-0.58,1.7
c-0.38,0.59-0.86,1.05-1.44,1.4l-7.41,4.38v0.74c0,0.33,0.03,0.8,0.08,1.43l7.32-4.33c0.58-0.34,1.06-0.45,1.44-0.33
c0.38,0.13,0.58,0.45,0.58,0.97c0,0.55-0.19,1.12-0.58,1.7c-0.38,0.59-0.86,1.05-1.44,1.39l-6.38,3.81
c0.8,1.34,1.98,2.03,3.56,2.07c1.58,0.04,3.37-0.53,5.37-1.73c1.73-1.03,3.29-2.46,4.69-4.28c0.33-0.36,0.69-0.66,1.07-0.88
c0.6-0.36,1.08-0.41,1.44-0.16C399.27,482.07,399.44,482.42,399.44,482.88z"/>
<path id="currency-pound" fill="#F07A28" d="M398.65,482.29c0.28,0.19,0.42,0.53,0.42,1.01c0,0.57-0.19,1.13-0.56,1.71c-0.38,0.57-0.97,1.21-1.77,1.93
c-1.08,1.04-2.26,1.9-3.55,2.57c-1,0.52-2.81,1.13-5.45,1.86c-2.42,0.64-4.06,1.18-4.92,1.63c-1.08,0.56-2.34,1.41-3.79,2.57
c-0.32,0.22-0.66,0.53-1.01,0.93c-0.48,0.47-0.83,0.76-1.05,0.87c-0.4,0.21-0.75,0.24-1.05,0.08c-0.3-0.15-0.44-0.46-0.44-0.92
c0-0.48,0.15-0.98,0.44-1.48c0.3-0.5,0.71-1,1.25-1.5c1.08-0.91,2.1-1.71,3.07-2.4c0.65-1.38,0.97-2.83,0.97-4.33
c0-1.4-0.31-2.89-0.93-4.48l-2.54,1.32c-0.51,0.26-0.93,0.32-1.27,0.15c-0.34-0.16-0.5-0.5-0.5-1.01c0-0.46,0.17-0.93,0.5-1.41
c0.34-0.48,0.76-0.86,1.27-1.12l1.53-0.79c-0.32-1.07-0.48-2.06-0.48-2.98c0-1.75,0.36-3.5,1.09-5.24
c0.73-1.75,1.77-3.35,3.15-4.82c1.37-1.46,2.99-2.68,4.84-3.64c1.24-0.64,2.42-1.08,3.55-1.32c1.13-0.24,2.08-0.23,2.86,0.01
c1.13,0.14,1.69,0.59,1.69,1.34c0,0.51-0.19,1.07-0.58,1.68c-0.39,0.61-0.85,1.05-1.39,1.33c-0.27,0.14-0.53,0.22-0.79,0.25
s-0.45-0.01-0.58-0.1c-1.24-0.68-2.81-0.52-4.72,0.47c-1.59,0.82-2.84,2-3.77,3.53c-0.93,1.53-1.39,3.05-1.39,4.55
c0,0.75,0.17,1.71,0.52,2.87l7.38-3.83c0.51-0.27,0.93-0.32,1.27-0.17c0.34,0.15,0.5,0.48,0.5,0.99c0,0.48-0.17,0.97-0.5,1.45
c-0.34,0.48-0.76,0.86-1.27,1.12l-6.29,3.26c0.56,1.4,0.85,2.63,0.85,3.68c0,1.53-0.42,3.21-1.25,5.04
c0.67-0.32,1.32-0.57,1.96-0.73s1.5-0.37,2.6-0.62c1.08-0.26,1.94-0.49,2.58-0.67c0.65-0.19,1.28-0.44,1.9-0.76
c0.51-0.27,1.05-0.64,1.63-1.13c0.58-0.49,1.07-0.96,1.47-1.41c0.51-0.59,0.98-0.99,1.41-1.22
C397.98,482.13,398.36,482.1,398.65,482.29z"/>
</g>
</svg>
For some reason, the delay is not respected and the currency usd/euro/pound are on top of each over.
Where did I fail?
The usd animation starts at 0s runs for 5s and then repeats indefinitely.
The start of its second time through coincides with the start of the euro animation. So both run together.
The third time through, pound starts and all three continue looping together indefinitely.
You need to make sure that only one shows at a time. One way is to use the keyframes to hide the symbol and keep it hidden while the other two animate.
#keyframes appearUp {
0% {
opacity: 1;
transform: translate(0, 5px);
}
33% {
opacity: 1;
transform: translate(0, -5px);
}
34% {
opacity: 0;
}
}
#currency-usd,
#currency-euro,
#currency-pound {
opacity: 0;
}
#currency-usd {
animation: appearUp 15s ease-out 0s infinite;
}
#currency-euro {
animation: appearUp 15s ease-out 5s infinite;
}
#currency-pound {
animation: appearUp 15s ease-out 10s infinite;
}
<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="Roundblockcurrency">
<linearGradient id="SVGID_454_" gradientUnits="userSpaceOnUse" x1="379.3599" y1="466.0918" x2="379.3599" y2="508.5988"><stop offset="0" style="stop-color: rgb(124, 10, 103);"></stop><stop offset="1" style="stop-color: rgb(178, 18, 85);"></stop></linearGradient>
<path fill-rule="evenodd" clip-rule="evenodd" fill="url(#SVGID_454_)" d="M352.21,531.89l0-0.05v-61.9 c12.06-11.81,31.17-21.38,54.29-28.16v61.9c-23.13,6.78-42.23,16.35-54.29,28.16L352.21,531.89L352.21,531.89z"></path>
<path id="currency-usd" fill-rule="evenodd" clip-rule="evenodd" fill="#F07A28" d="M397.79,477.91c0,2-0.68,4.13-2.05,6.39
c-1.37,2.26-3.11,4.3-5.24,6.14v2.42c0,0.68-0.23,1.39-0.69,2.14c-0.46,0.75-1.03,1.35-1.72,1.79c-0.66,0.42-1.21,0.55-1.66,0.38
c-0.45-0.16-0.67-0.59-0.67-1.26v-2.18c-1.42,0.78-2.71,1.32-3.88,1.61c-1.17,0.29-2.31,0.32-3.41,0.09
c-0.71-0.17-1.06-0.63-1.06-1.38c0-0.6,0.22-1.27,0.67-2.01c0.45-0.74,0.98-1.32,1.62-1.72c0.5-0.32,0.95-0.46,1.34-0.4
c0.82,0.13,1.59,0.14,2.33,0.04c0.74-0.1,1.54-0.36,2.41-0.79v-7.6c-5.28,2.44-7.92,1.54-7.92-2.72c0-2.16,0.74-4.4,2.21-6.74
c1.47-2.34,3.38-4.42,5.72-6.23v-1.28c0-0.67,0.23-1.39,0.69-2.14c0.46-0.75,1.03-1.35,1.72-1.79c0.66-0.42,1.21-0.55,1.66-0.39
c0.45,0.17,0.67,0.59,0.67,1.26v1.44c2.23-1.05,4.07-1.43,5.52-1.14c0.76,0.1,1.14,0.55,1.14,1.33c0,0.6-0.22,1.27-0.67,2.01
c-0.45,0.74-0.97,1.31-1.58,1.7c-0.39,0.25-0.75,0.37-1.06,0.33c-0.79-0.14-1.91,0.02-3.35,0.48v7.21c2.55-1.05,4.4-1.36,5.56-0.95
C397.21,474.35,397.79,475.68,397.79,477.91L397.79,477.91z M382.49,475.65c0,0.86,0.28,1.37,0.83,1.55
c0.55,0.18,1.37,0.07,2.44-0.31v-6.47c-1.08,0.9-1.89,1.8-2.44,2.71C382.77,474.03,382.49,474.87,382.49,475.65L382.49,475.65z
M390.49,485.76c0.76-0.8,1.38-1.61,1.85-2.42c0.47-0.81,0.71-1.52,0.71-2.11c0-0.73-0.21-1.22-0.63-1.48
c-0.42-0.26-1.06-0.29-1.93-0.1V485.76L390.49,485.76z"/>
<path id="currency-euro" fill="#F07A28" d="M399.44,482.88c0,0.33-0.09,0.69-0.27,1.08c-0.18,0.4-0.42,0.77-0.72,1.11c-0.96,1.18-2.02,2.29-3.19,3.34
s-2.34,1.93-3.52,2.64c-3.02,1.8-5.72,2.57-8.1,2.31s-4.06-1.61-5.02-4.06l-2.3,1.38c-0.58,0.35-1.06,0.46-1.44,0.33
c-0.39-0.13-0.58-0.46-0.58-1.01s0.19-1.11,0.58-1.7c0.38-0.59,0.86-1.05,1.44-1.4l1.6-0.96c-0.03-0.29-0.04-0.76-0.04-1.42v-0.74
l-1.56,0.93c-0.58,0.35-1.06,0.45-1.44,0.33c-0.39-0.13-0.58-0.46-0.58-1.01s0.19-1.12,0.58-1.7c0.38-0.58,0.86-1.05,1.44-1.39
l2.18-1.3c0.55-2.33,1.46-4.64,2.74-6.94c1.28-2.3,2.82-4.41,4.63-6.34s3.77-3.53,5.88-4.79c1.18-0.71,2.34-1.23,3.47-1.56
c1.14-0.34,2.2-0.49,3.19-0.44c0.66-0.04,0.99,0.31,0.99,1.05c0,0.49-0.17,1.04-0.49,1.65c-0.33,0.64-0.78,1.13-1.36,1.47
c-0.38,0.23-0.75,0.35-1.11,0.38c-1.45-0.09-3.02,0.36-4.69,1.36c-2.11,1.26-3.98,2.94-5.61,5.04c-1.63,2.1-2.82,4.34-3.56,6.74
l6.62-3.92c0.58-0.35,1.06-0.45,1.44-0.33c0.38,0.13,0.58,0.45,0.58,0.97c0,0.55-0.19,1.12-0.58,1.7
c-0.38,0.59-0.86,1.05-1.44,1.4l-7.41,4.38v0.74c0,0.33,0.03,0.8,0.08,1.43l7.32-4.33c0.58-0.34,1.06-0.45,1.44-0.33
c0.38,0.13,0.58,0.45,0.58,0.97c0,0.55-0.19,1.12-0.58,1.7c-0.38,0.59-0.86,1.05-1.44,1.39l-6.38,3.81
c0.8,1.34,1.98,2.03,3.56,2.07c1.58,0.04,3.37-0.53,5.37-1.73c1.73-1.03,3.29-2.46,4.69-4.28c0.33-0.36,0.69-0.66,1.07-0.88
c0.6-0.36,1.08-0.41,1.44-0.16C399.27,482.07,399.44,482.42,399.44,482.88z"/>
<path id="currency-pound" fill="#F07A28" d="M398.65,482.29c0.28,0.19,0.42,0.53,0.42,1.01c0,0.57-0.19,1.13-0.56,1.71c-0.38,0.57-0.97,1.21-1.77,1.93
c-1.08,1.04-2.26,1.9-3.55,2.57c-1,0.52-2.81,1.13-5.45,1.86c-2.42,0.64-4.06,1.18-4.92,1.63c-1.08,0.56-2.34,1.41-3.79,2.57
c-0.32,0.22-0.66,0.53-1.01,0.93c-0.48,0.47-0.83,0.76-1.05,0.87c-0.4,0.21-0.75,0.24-1.05,0.08c-0.3-0.15-0.44-0.46-0.44-0.92
c0-0.48,0.15-0.98,0.44-1.48c0.3-0.5,0.71-1,1.25-1.5c1.08-0.91,2.1-1.71,3.07-2.4c0.65-1.38,0.97-2.83,0.97-4.33
c0-1.4-0.31-2.89-0.93-4.48l-2.54,1.32c-0.51,0.26-0.93,0.32-1.27,0.15c-0.34-0.16-0.5-0.5-0.5-1.01c0-0.46,0.17-0.93,0.5-1.41
c0.34-0.48,0.76-0.86,1.27-1.12l1.53-0.79c-0.32-1.07-0.48-2.06-0.48-2.98c0-1.75,0.36-3.5,1.09-5.24
c0.73-1.75,1.77-3.35,3.15-4.82c1.37-1.46,2.99-2.68,4.84-3.64c1.24-0.64,2.42-1.08,3.55-1.32c1.13-0.24,2.08-0.23,2.86,0.01
c1.13,0.14,1.69,0.59,1.69,1.34c0,0.51-0.19,1.07-0.58,1.68c-0.39,0.61-0.85,1.05-1.39,1.33c-0.27,0.14-0.53,0.22-0.79,0.25
s-0.45-0.01-0.58-0.1c-1.24-0.68-2.81-0.52-4.72,0.47c-1.59,0.82-2.84,2-3.77,3.53c-0.93,1.53-1.39,3.05-1.39,4.55
c0,0.75,0.17,1.71,0.52,2.87l7.38-3.83c0.51-0.27,0.93-0.32,1.27-0.17c0.34,0.15,0.5,0.48,0.5,0.99c0,0.48-0.17,0.97-0.5,1.45
c-0.34,0.48-0.76,0.86-1.27,1.12l-6.29,3.26c0.56,1.4,0.85,2.63,0.85,3.68c0,1.53-0.42,3.21-1.25,5.04
c0.67-0.32,1.32-0.57,1.96-0.73s1.5-0.37,2.6-0.62c1.08-0.26,1.94-0.49,2.58-0.67c0.65-0.19,1.28-0.44,1.9-0.76
c0.51-0.27,1.05-0.64,1.63-1.13c0.58-0.49,1.07-0.96,1.47-1.41c0.51-0.59,0.98-0.99,1.41-1.22
C397.98,482.13,398.36,482.1,398.65,482.29z"/>
</g>
</svg>

Unable to apply line drawing and filling it animation in svg

I want a line drawing animation and I tried to follow some youtube tutorials and I want something like this https://codepen.io/shshaw/pen/Hjyio which first draw the logo then fills it. Till now I tried this but failed miserably. I searched every other question on stack overflow question everyone tell about only line drawing animation but I want to fill it also.
Also I don't draw any line animation.
Any suggestion of where I am wrong and also adding px unit don't help at all ?
<!DOCTYPE html>
<html>
<head>
<title>SVG</title>
<style>
path {
stroke:#000;
stroke-dasharray: 2500;
stroke-width:3;
animation: my_animation 100s;
}
#keyframes my_animation{
0%{
stroke-dashoffset: 0;
}
50%{
stroke-dashoffset: 2500;
}
100%{
stroke-dashoffset: 0;
}
}
</style>
</head>
<body>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" viewBox="0 0 640 640" width="640" height="640"><defs><path d="M479 320L639 0L318.99 0L-1 0L158.98 320L318.99 640L479 320Z" id="aLRf203Rm"></path><path d="M301.47 203.41L401.95 0L200.97 0L0 0L100.48 203.41L200.97 406.83L301.47 203.41Z" id="a1ManYbeyy"></path></defs><g><g><use xlink:href="#aLRf203Rm" opacity="1" fill="#ff0043" fill-opacity="1"></use><g><use xlink:href="#aLRf203Rm" opacity="1" fill-opacity="0" stroke="#ff0043" stroke-width="1" stroke-opacity="1"></use></g></g><g><use xlink:href="#a1ManYbeyy" opacity="1" fill="#00ffda" fill-opacity="1"></use><g><use xlink:href="#a1ManYbeyy" opacity="1" fill-opacity="0" stroke="#00ffda" stroke-width="1" stroke-opacity="1"></use></g></g></g></svg>
</body>
</html>
Just use your keyframes. In this example, I have made the stroke animation run from time 0% to 80%. Then I make the fill fade in using fill-opacity from time 80% to 100%.
path {
stroke:#000;
stroke-dasharray: 2072;
stroke-width:3;
animation: my_animation 4s;
animation-fill-mode: forwards;
fill: red;
}
#keyframes my_animation{
0%{
stroke-dashoffset: 2072;
fill-opacity: 0;
}
80%{
stroke-dashoffset: 0;
fill-opacity: 0;
}
100%{
fill-opacity: 1;
}
}
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" viewBox="0 0 640 640" width="640" height="640"><defs><path d="M479 320L639 0L318.99 0L-1 0L158.98 320L318.99 640L479 320Z" id="aLRf203Rm"></path><path d="M301.47 203.41L401.95 0L200.97 0L0 0L100.48 203.41L200.97 406.83L301.47 203.41Z" id="a1ManYbeyy"></path></defs><g><g><use xlink:href="#aLRf203Rm" opacity="1" fill="#ff0043" fill-opacity="1"></use><g><use xlink:href="#aLRf203Rm" opacity="1" fill-opacity="0" stroke="#ff0043" stroke-width="1" stroke-opacity="1"></use></g></g><g><use xlink:href="#a1ManYbeyy" opacity="1" fill="#00ffda" fill-opacity="1"></use><g><use xlink:href="#a1ManYbeyy" opacity="1" fill-opacity="0" stroke="#00ffda" stroke-width="1" stroke-opacity="1"></use></g></g></g></svg>

i want to animate this logo but for some reason it doesn't work

<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"
width="340px" height="333px" viewBox="0 0 340 333" enable-background="new 0 0 340 333" xml:space="preserve">
<defs>
<style>
.path {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear alternate infinite;
}
#keyframes dash {
from {
stroke-dashoffset: 1000;
}
to {
stroke-dashoffset: 0;
}
}
</style>
</defs>
<title>logo</title>
<path class="path" d="M115.59,123.26l39.56-31c0.63-.5-0.26-1.38-0.88-0.88l-39.56,31c-0.63.5,0.26,1.38,0.88,0.88h0Z" transform="translate(-93.82 -21.1)" />
<path class="path" d="M94.71,73.09l35.54-.51a0.63,0.63,0,0,0,0-1.25l-35.54.51a0.63,0.63,0,0,0,0,1.25h0Z" transform="translate(-93.82 -21.1)" />
<path class="path" d="M95.1,121.61l0-86.41V22.81a0.63,0.63,0,0,0-1.25,0l0,86.41v12.39a0.63,0.63,0,0,0,1.25,0h0Z" transform="translate(-93.82 -21.1)" />
<path class="path" d="M155.15,91.35l-15.9-19.21c-0.51-.62-1.39.27-0.88,0.88l15.9,19.21c0.51,0.62,1.39-.27.88-0.88h0Z" transform="translate(-93.82 -21.1)" />
<path class="path" d="M154.57,52.56L138.36,72.14c-0.51.62,0.37,1.5,0.88,0.88l16.21-19.58c0.51-.62-0.37-1.5-0.88-0.88h0Z" transform="translate(-93.82 -21.1)" />
<path class="path" d="M114.71,22.13l39.56,31c0.63,0.49,1.52-.39.88-0.88l-39.56-31c-0.63-.49-1.52.39-0.88,0.88h0Z" transform="translate(-93.82 -21.1)" />
</svg>
i want this svg logo to looks like its drawn with css animation. can someone help me fix this problem. its already on the page it doesn't animate
Currently, your svg doesn't have a stroke (what you see is actually the fill). Remove the fill and add a stroke, and your animation will kick in:
.path {
stroke: black;
fill: none;
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear alternate infinite;
}