Scss map for animation - animation
Help pleath, how to mate loop on scss for that HTML code
.pot_st0 {
fill: #15630D;
}
.pot_st1 {
fill: #012D3F;
}
.pot_st2 {
fill: #013D51;
}
.pot_st3 {
fill: #01445F;
}
.pot_st4 {
fill: none;
stroke: #011F2B;
stroke-width: 13;
stroke-linecap: round;
stroke-linejoin: round;
stroke-miterlimit: 10;
}
.pot_st5 {
opacity: 0.2;
fill: #012D3F;
enable-background: new;
}
.pot_st6 {
fill: #011F2B;
}
.pot_st7 {
clip-path: url(#SVGID_2_);
}
.pot_st8 {
fill: #FFD900;
}
.pot_st9 {
fill: #FFE935;
}
.pot_st10 {
fill: #FFAE00;
}
.pot_st11 {
fill: #FF8A00;
}
.pot_st12 {
fill: #FF7A00;
}
.pot_st13 {
fill: #DD5300;
}
.pot_st14 {
fill: #015C8C;
}
$translateMyCoin: (
translateCoin1: translate(0, -100),
translateCoin2: translate(-100, 10),
translateCoin3: translate(-80, 5),
translateCoin4: translate(-60, 10),
translateCoin5: translate(-70, 11),
translateCoin6: translate(-75, 7),
translateCoin7: translate(-60, 10),
translateCoin8: translate(-20, 8),
translateCoin9: translate(0, -5),
translateCoin10: translate(30, 10),
translateCoin11: translate(30, -17),
translateCoin12: translate(-40, -10),
translateCoin13: translate(-65, -20),
translateCoin14: translate(-95, -15),
translateCoin15: translate(-105, -5),
translateCoin16: translate(-75, -15),
translateCoin17: translate(-20, -25),
translateCoin18: translate(-10, -5),
translateCoin19: translate(-40, -15),
translateCoin20: translate(5, -25)
);
#for $i from 1 through 20 {
.animateCoin:nth-child(#{$i}) {
animation: coinMoving+$i 1s ease-out;
animation-fill-mode: forwards;
}
}
#for $i from 1 through 20 {
#keyframes coinMoving {
0% {transform: translate(0, -100);}
100% {
transform: #{map-get($translateMyCoin,'translate'+$i)};
}
}
}
<svg version="1.1" id="svg_pot" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 337 340" pot_style="enable-background:new 0 0 337 340;" xml:space="preserve">
<g id="money" class="pot_st7">
<defs>
<g id="coin">
<circle class="pot_st8" cx="205.8" cy="145.2" r="15"/>
<path class="pot_st9" d="M205.8,130.7h-0.3l-14.2,14.2v0.3c0,2.7,0.7,5.2,2,7.4l19.8-19.8C211,131.4,208.5,130.7,205.8,130.7
L205.8,130.7z M220.2,143.5c-0.2-1.8-0.8-3.5-1.6-5.1L199,158c1.5,0.8,3.3,1.4,5.1,1.6L220.2,143.5L220.2,143.5z M196.1,155.9
l20.5-20.5l-0.9-0.9L195.2,155L196.1,155.9z"/>
<circle class="pot_st8" cx="205.8" cy="145.2" r="11.8"/>
<circle class="pot_st10" cx="205.8" cy="145.2" r="10.5"/>
<path class="pot_st11" d="M205.8,135.1c5.7,0,10.4,4.6,10.5,10.3v-0.2c0-5.8-4.7-10.5-10.5-10.5s-10.5,4.7-10.5,10.5v0.2
C195.4,139.7,200.1,135.1,205.8,135.1z"/>
<path class="pot_st8" d="M211.6,149.8l-2.2-2.2c0.1,0,0.2,0,0.4-0.1c1.3-0.3,2-1.6,1.7-2.9c-0.2-0.6-0.6-1.2-1.1-1.5
c0.3-0.5,0.4-1.2,0.3-1.8c-0.3-1.1-1.2-1.8-2.3-1.8c-0.2,0-0.4,0-0.6,0.1c-0.6,0.2-1.2,0.6-1.5,1.1c0-0.6-0.3-1.1-0.7-1.5
c-0.9-0.9-2.5-0.9-3.4,0c-0.5,0.5-0.7,1.1-0.7,1.7c-0.7,0-1.3,0.2-1.7,0.7c-0.9,0.9-0.9,2.5,0,3.4c0.4,0.4,0.9,0.6,1.5,0.7
c-0.5,0.3-0.8,0.8-1,1.4c-0.2,0.6-0.1,1.3,0.2,1.8c0.3,0.6,0.8,0.9,1.5,1.1c0.6,0.2,1.3,0.1,1.8-0.3c0.3,0.6,0.8,1,1.5,1.1
c1.3,0.3,2.6-0.5,2.9-1.7c0-0.1,0.1-0.2,0.1-0.4l2.2,2.2c0.2,0.2,0.4,0.2,0.6,0.2c0.2,0,0.4-0.1,0.6-0.2
C211.9,150.6,211.9,150.1,211.6,149.8z"/>
<path class="pot_st12" d="M211.3,150l-3-3c0.4,0.2,0.9,0.3,1.4,0.1c1.1-0.3,1.7-1.4,1.4-2.5c-0.2-0.7-0.7-1.2-1.4-1.4
c0.5-0.5,0.7-1.2,0.5-1.9c-0.3-1.1-1.4-1.7-2.5-1.4c-0.7,0.2-1.2,0.7-1.4,1.4l-0.7,1.5l0.2-1.7c0.1-0.6-0.1-1.3-0.6-1.7
c-0.8-0.8-2.1-0.8-2.8,0c-0.5,0.5-0.7,1.2-0.5,1.9c-0.7-0.2-1.4,0-1.9,0.5c-0.8,0.8-0.8,2.1,0,2.8c0.5,0.5,1.3,0.7,1.9,0.5
l1.4-0.1l-1.3,0.6c-0.7,0.2-1.2,0.7-1.4,1.4c-0.3,1.1,0.4,2.2,1.4,2.5c0.7,0.2,1.4,0,1.9-0.5c0.2,0.6,0.7,1.2,1.4,1.4
c1.1,0.3,2.2-0.4,2.5-1.4c0.1-0.5,0.1-1-0.1-1.4l3,3c0.2,0.2,0.4,0.2,0.6,0C211.5,150.5,211.5,150.2,211.3,150L211.3,150z"/>
<path class="pot_st13" d="M210.2,143.7v-0.2c-0.2-0.1-0.3-0.2-0.5-0.2v0.4H210.2z M209.7,143.2
C209.7,143.3,209.7,143.3,209.7,143.2z"/>
<path class="pot_st13" d="M205.6,143.2l0.7-1.5c0.2-0.7,0.7-1.2,1.4-1.4c1.1-0.3,2.2,0.4,2.5,1.4v-0.4c-0.3-1.1-1.4-1.7-2.5-1.4
c-0.7,0.2-1.2,0.7-1.4,1.4l-0.6,1.4L205.6,143.2L205.6,143.2z M202,146.1l1.3-0.6l-1.1,0.1l-0.2,0.1c-0.7,0.2-1.2,0.7-1.4,1.4
c-0.1,0.2-0.1,0.5-0.1,0.7c0-0.1,0-0.2,0.1-0.3C200.8,146.8,201.3,146.3,202,146.1z M209.7,143.7c0.6,0.2,1.2,0.7,1.4,1.4v-0.4
c-0.2-0.6-0.6-1.1-1.1-1.3L209.7,143.7L209.7,143.7z M208.3,147.4l3,3c0,0,0,0.1,0.1,0.1c0.1-0.2,0.1-0.4-0.1-0.5l-3-3V147.4z
M202.4,139.8c0.8-0.8,2.1-0.8,2.8,0c0.3,0.3,0.5,0.8,0.6,1.2c0.1-0.6-0.1-1.2-0.6-1.6c-0.8-0.8-2.1-0.8-2.8,0
c-0.4,0.4-0.6,1-0.6,1.6C201.9,140.6,202.1,140.1,202.4,139.8z M200,142.2c0.5-0.5,1.2-0.7,1.9-0.5v-0.4
c-0.6-0.1-1.3,0-1.9,0.5c-0.4,0.4-0.6,1-0.6,1.6C199.4,143,199.6,142.6,200,142.2L200,142.2z"/>
</g>
</defs>
<use id="coin1" class="animateCoin" xlink:href="#coin" transform="translate(0, -100)"/>
<use id="coin2" class="animateCoin" xlink:href="#coin" transform="translate(-100, 10)" />
<use id="coin3" class="animateCoin" xlink:href="#coin" transform="translate(-80, 5)" />
<use id="coin4" class="animateCoin" xlink:href="#coin" transform="translate(-60, 10)" />
<use id="coin5" class="animateCoin" xlink:href="#coin" transform="translate(-70, 11)" />
<use id="coin6" class="animateCoin" xlink:href="#coin" transform="translate(-75, 7)" />
<use id="coin7" class="animateCoin" xlink:href="#coin" transform="translate(-60, 10)" />
<use id="coin8" class="animateCoin" xlink:href="#coin" transform="translate(-20, 8)" />
<use id="coin9" class="animateCoin" xlink:href="#coin" transform="translate(0, -5)" />
<use id="coin10" class="animateCoin" xlink:href="#coin" transform="translate(30, 10)" />
<use id="coin11" class="animateCoin" xlink:href="#coin" transform="translate(30, -17)" />
<use id="coin12" class="animateCoin" xlink:href="#coin" transform="translate(-40, -10)" />
<use id="coin13" class="animateCoin" xlink:href="#coin" transform="translate(-65, -20)" />
<use id="coin14" class="animateCoin" xlink:href="#coin" transform="translate(-95, -15)" />
<use id="coin15" class="animateCoin" xlink:href="#coin" transform="translate(-105, -5)" />
<use id="coin16" class="animateCoin" xlink:href="#coin" transform="translate(-75, -15)" />
<use id="coin17" class="animateCoin" xlink:href="#coin" transform="translate(-20, -25)" />
<use id="coin18" class="animateCoin" xlink:href="#coin" transform="translate(-10, -5)" />
<use id="coin19" class="animateCoin" xlink:href="#coin" transform="translate(-40, -15)" />
<use id="coin20" class="animateCoin" xlink:href="#coin" transform="translate(5, -25)" />
</g>
</svg>
I need that each coin moving from transform:translate(0, -100); to $translateMyCoin value How to fix it ? If the first part of the code, still somehow works, then the second one does not. I can not figure out how to correctly set the loop for #keyframes
https://codepen.io/anon/pen/
Related
Hard svg animation
I need your help with the implementation of svg animation. https://youtu.be/lrWjkARl8Zg (sorry for the poor video quality) And I have such a structure of svg I need the arrow (class = "arrow") itself to move along long lines and draw it. <svg class="vector" width="1193" height="329" viewBox="0 0 1193 329" fill="none" xmlns="http://www.w3.org/2000/svg"> <path class="long_line" d="M1436 327.98L84.7148 327.98C73.8082 328.219 62.9639 326.275 52.818 322.262C42.6722 318.249 33.4293 312.249 25.6315 304.613C17.8337 296.977 11.6384 287.858 7.40866 277.793C3.17891 267.728 0.999997 256.919 0.999996 246C0.999996 235.081 3.17891 224.272 7.40866 214.207C11.6384 204.142 17.8337 195.023 25.6315 187.387C33.4292 179.751 42.6722 173.75 52.818 169.738C62.9638 165.725 73.8082 163.781 84.7147 164.02L589.173 164.02" stroke="black" stroke-width="2" stroke-miterlimit="10"/> <path class="arrow" d="M544 204L589 164L548 124" stroke="black" stroke-width="2"/> <path class="arrow" d="M504 1L459 41L500 81" stroke="black" stroke-width="2"/> <path class="short_line" d="M1308 41L459 41" stroke="black" stroke-width="2" stroke-miterlimit="10"/> </svg> Advise which library I can use
You could do this using svg smil animations: A Guide to SVG Animations (SMIL) Your arrow animations could be achieved by <animateMotion> for moving the arrow element and animating the stroke-dashoffset property. Animated example svg { border: 1px solid #ccc; width: 33%; overflow: visible; display: block; } path { stroke-width: 10; stroke: #000; } <p>Click on animation for replay</p> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1400 500"> <defs> <path id="arrow" fill="none" d="M-45,40L0,0l-41-40" /> </defs> <use id="arrow1" href="#arrow" /> <use id="arrow2" href="#arrow" /> <g id="graphics"> <rect id="graphics" fill="#fff" fill-opacity="0" x="0" y="0" width="100%" height="100%" /> <path id="mpath-long" fill="none" pathLength="100" stroke-width="2" stroke-miterlimit="10" stroke-dashoffset="100" stroke-dasharray="100" d="M1571,413H219.7 c-10.9,0.2-21.8-1.7-31.9-5.7c-10.1-4-19.4-10-27.2-17.6c-7.8-7.6-14-16.8-18.2-26.8S136,341.9,136,331s2.2-21.7,6.4-31.8 s10.4-19.2,18.2-26.8c7.8-7.6,17-13.6,27.2-17.6c10.1-4,21-6,31.9-5.7h504.5" /> <path id="mpath-short" fill="none" pathLength="100" stroke-width="2" stroke-miterlimit="10" stroke-dashoffset="100" stroke-dasharray="100" d="M1443,126H594" /> </g> <animateMotion href="#arrow1" dur="2" rotate="auto" repeatCount="1" begin="0;graphics.click" fill="freeze"> <mpath href="#mpath-long" /> </animateMotion> <animate attributeType="XML" href="#mpath-long" id="strokeAni" attributeName="stroke-dashoffset" from="100" to="0" dur="2s" repeatCount="1" begin="0;graphics.click" fill="freeze" /> <animateMotion href="#arrow2" dur="2s" rotate="auto" repeatCount="1" begin="0;graphics.click" fill="freeze"> <mpath href="#mpath-short" /> </animateMotion> <animate attributeType="XML" href="#mpath-short" attributeName="stroke-dashoffset" from="100" to="0" dur="2s" repeatCount="1" fill="freeze" begin="0;graphics.click" /> </svg> Quite likely, you will have to tweak your svg viewBox to get the desired result. A common trick is to position element that's supposed to move along the motion path to x/y = 0. Static example <style> svg{ border: 1px solid #ccc; width: 33%; overflow:visible; display:block; } path{ stroke-width:10; stroke: #000; } </style> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1400 500"> <defs> <path id="arrow" fill="none" d="M-45,40L0,0l-41-40" /> </defs> <use id="arrow1" href="#arrow" /> <use id="arrow2" href="#arrow" /> <g id="graphics"> <rect id="graphics" fill="#fff" fill-opacity="0" x="0" y="0" width="100%" height="100%" /> <path id="mpath-long" fill="none" pathLength="100" stroke-width="2" stroke-miterlimit="10" stroke-dashoffset="0" stroke-dasharray="100" d="M1571,413H219.7 c-10.9,0.2-21.8-1.7-31.9-5.7c-10.1-4-19.4-10-27.2-17.6c-7.8-7.6-14-16.8-18.2-26.8S136,341.9,136,331s2.2-21.7,6.4-31.8 s10.4-19.2,18.2-26.8c7.8-7.6,17-13.6,27.2-17.6c10.1-4,21-6,31.9-5.7h504.5" /> <path id="mpath-short" fill="none" pathLength="100" stroke-width="2" stroke-miterlimit="10" stroke-dashoffset="0" stroke-dasharray="100" d="M1443,126H594" /> </g> </svg>
Draw a braid woven with 3 lines in SVG
I'm trying to archive a result similar to this one: Where red line is passing behind blue one, but still above green. So far I managed to create the lines. What is the order of drawing that will create correct stacking? Snippet: https://observablehq.com/d/91f99a7dfdaeb71f const svg = d3.create("svg").attr("width", 500).attr("height", 100); const segment = 80; const ratio = 0.2; const flat = segment * ratio; const slope = segment - flat; const width = 15; const top = 10; const btm = 90; const offset = -200; for (let i = 0; i < 10; i++) { const isUp = !(i % 2); for (let j = 0; j < 3; j++) { const color = ["darkred", "darkgreen", "darkblue"][j % 3]; const spacings = [0, (segment / 3) * 2, (segment / 3) * 4].map( (x) => x + offset ); const spacing = spacings[j % 3]; svg .append("line") .attr("x1", segment * i + spacing) .attr("x2", segment * i + slope + spacing) .attr("y1", isUp ? top : btm) .attr("y2", isUp ? btm : top) .attr("stroke", color) .attr("stroke-width", width) .attr("stroke-linecap", "round"); svg .append("line") .attr("x1", segment * i + slope + spacing) .attr("x2", segment * i + slope + flat + spacing) .attr("y1", isUp ? btm : top) .attr("y2", isUp ? btm : top) .attr("stroke", color) .attr("stroke-width", width) .attr("stroke-linecap", "round"); } } return svg.node();
This is possible with clever use of defs and masking mixed with CSS variables: <svg width="520" height="60" viewBox="0 0 137.583 15.875" xmlns="http://www.w3.org/2000/svg"> <defs> <path id="red" style="fill:none;stroke:var(--stroke, transparent);stroke-width:4.23333333;stroke-linecap:butt;stroke-linejoin:round;" d="M-3.237 2.646h14.111l14.111 10.583h7.056L46.15 2.646h7.056L67.32 13.229h7.055L88.485 2.646h7.056l14.11 10.583h7.056L130.82 2.646h7.055l3.314-.054" /> <path id="green" style="fill:none;stroke:var(--stroke, transparent);stroke-width:4.23333333;stroke-linecap:butt;stroke-linejoin:round;" d="M-3.656 7.941H3.4l7.474 5.288h7.056L32.04 2.646h7.056l14.111 10.583h7.056L74.374 2.646h7.056l14.11 10.583h7.056l14.111-10.583h7.056l8.453 5.292h7.056l1.733-.052" /> <path id="blue" style="fill:none;stroke:var(--stroke, transparent);stroke-width:4.23333333;stroke-linecap:butt;stroke-linejoin:round;" d="M-3.237 13.23h7.056l14.11-10.584h7.056l14.111 10.583h7.056L60.263 2.646h7.056l14.11 10.583h7.056l14.111-10.583h7.056l14.111 10.583h14.111l3.058-.158" /> <rect id="bg" x="0" y="0" width="137.583" height="15.875" fill="white" /> <filter id="shadow"> <feGaussianBlur in="SourceGraphic" stdDeviation="1" /> </filter> <mask id="redmask"> <use href="#bg" /> <use href="#red" x="0" y="0" style="--stroke:#000000" /> <use href="#red" x="0" y="0" style="--stroke:#000000" filter="url(#shadow)" /> </mask> <mask id="greenmask"> <use href="#bg" /> <use href="#green" x="0" y="0" style="--stroke:#000000" /> <use href="#green" x="0" y="0" style="--stroke:#000000" filter="url(#shadow)" /> </mask> <mask id="bluemask"> <use href="#bg" /> <use href="#blue" x="0" y="0" style="--stroke:#000000" /> <use href="#blue" x="0" y="0" style="--stroke:#000000" filter="url(#shadow)" /> </mask> </defs> <use href="#red" x="0" y="0" /> <use href="#red" x="0" y="0" mask="url(#bluemask)" style="--stroke:#660000" /> <use href="#green" x="0" y="0" mask="url(#redmask)" style="--stroke:#006600" /> <use href="#blue" x="0" y="0" mask="url(#greenmask)" style="--stroke:#000066" /> </svg>
SVG animate gradient along path
I have the following svg that i would like to animate. I would like the red part moves along the path up to the end (so from the top right side to the left bottom side) : The problem is : obviously is quite impossible to have a gradient following a path. Here is my code so far : <svg id="fil" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 783.53 362"> <defs> <style> .cls-3{ fill: none; stroke-miterlimit:10; stroke-width:3px; } </style> <linearGradient id="light" x1="100%" y1="100%"> <stop offset="70%" stop-color="#3E3E3E"> <!-- <animate attributeName="stop-color" to="#CF4B59" from="#3E3E3E" dur="0.5s" fill="freeze" /> --> </stop> <stop offset="100%" stop-color="#CF4B59"> <!-- <animate attributeName="stop-color" from="#CF4B59" to="#3E3E3E" dur="0.5s" fill="freeze" /> --> </stop> </linearGradient> </defs> <g id="Calque_2" data-name="Calque 2"> <g id="Calque_1-2" data-name="Calque 1"> <g class="cls-2"> <path class="cls-3" id="base" d="M656.89,8.93c0,48,7.42,124.9,64.45,125.92a115.56,115.56,0,0,0,53.83-12.28c8.35-4.2,16.35-9.59,21.84-17.15s8.15-17.62,5.25-26.51c-3.12-9.53-12.16-16.28-21.87-18.83-61.57-16.19-142.83,57.7-139.63,119.4,1.23,23.69,16.72,41.59,37.61,51.29,27,12.55,60.55,13.36,89.45,8.06,12.25-2.25,25.82-5.25,37.26-10.44,12.63-5.72,32.28-20.08,28.88-36.64a18,18,0,0,0-15.63-14.59c-10.28-1.4-19.14,3.57-26.76,10-16.18,13.66-29.34,30.65-44.7,45.2a359.34,359.34,0,0,1-49.33,39.08A356.65,356.65,0,0,1,638.08,303c-35.77,14.83-90.88,29.56-123.22-.47-11.61-10.78-17.61-26.71-18.41-42.53-1.07-21.19,4.41-54.95,30-59.28,36.67-6.2,78.65,49.05,86.38,79.36,8.2,32.14-5.44,70.78-35.75,84.26-28.8,12.81-63.93,0-85.8-22.72-23.52-24.41-18.59-55.9-36.07-82.56-16-24.39-41.3-23.5-66.77-24.62" transform="translate(-52.32 -8.93)" stroke="url(#light)"/> </g> </g> </g> </svg> I tried to use "animate" to make it move along the path, but it's a vertical gradient which is applied and goes from the top to the bottom and not a gradient which follows the path. I had other ideas to overcome this : Maybe by using a second path which would be the same shape than the first one but with inverted gradient so I could make it slide along the initial path maybe Or, I could use opacity to make the final path appear but i'm not sure i will be able to make the red part move in this way... If you have some ideas to make the red part move from the top right to the bottom left it would help me a lot!
Question I would like the red part moves along the path up to the end (so from the top right side to the left bottom side) : Consider using fill-line animation with stroke-dashoffset. For clarity, I placed exactly the same curve below which will show the route of filling the line with color If this indication of the motion path is not necessary, simply remove the path id = "trace" <svg id="fil" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 783.53 362"> <defs> <style> .cls-3{ fill: none; stroke-miterlimit:10; stroke-width:3px; stroke:#E7E7E7; } #base { fill: none; stroke:crimson; stroke-width:3px; stroke-dashoffset:1732; stroke-dasharray:1732; animation: fillStroke 10s linear forwards; } #keyframes fillStroke { to {stroke-dashoffset:0;} } </style> </defs> <g transform="translate(-352.32 -8.93)"> <path id="trace" class="cls-3" d="M656.89,8.93c0,48,7.42,124.9,64.45,125.92a115.56,115.56,0,0,0,53.83-12.28c8.35-4.2,16.35-9.59,21.84-17.15s8.15-17.62,5.25-26.51c-3.12-9.53-12.16-16.28-21.87-18.83-61.57-16.19-142.83,57.7-139.63,119.4,1.23,23.69,16.72,41.59,37.61,51.29,27,12.55,60.55,13.36,89.45,8.06,12.25-2.25,25.82-5.25,37.26-10.44,12.63-5.72,32.28-20.08,28.88-36.64a18,18,0,0,0-15.63-14.59c-10.28-1.4-19.14,3.57-26.76,10-16.18,13.66-29.34,30.65-44.7,45.2a359.34,359.34,0,0,1-49.33,39.08A356.65,356.65,0,0,1,638.08,303c-35.77,14.83-90.88,29.56-123.22-.47-11.61-10.78-17.61-26.71-18.41-42.53-1.07-21.19,4.41-54.95,30-59.28,36.67-6.2,78.65,49.05,86.38,79.36,8.2,32.14-5.44,70.78-35.75,84.26-28.8,12.81-63.93,0-85.8-22.72-23.52-24.41-18.59-55.9-36.07-82.56-16-24.39-41.3-23.5-66.77-24.62" /> <g class="cls-2"> <path id="base" d="M656.89,8.93c0,48,7.42,124.9,64.45,125.92a115.56,115.56,0,0,0,53.83-12.28c8.35-4.2,16.35-9.59,21.84-17.15s8.15-17.62,5.25-26.51c-3.12-9.53-12.16-16.28-21.87-18.83-61.57-16.19-142.83,57.7-139.63,119.4,1.23,23.69,16.72,41.59,37.61,51.29,27,12.55,60.55,13.36,89.45,8.06,12.25-2.25,25.82-5.25,37.26-10.44,12.63-5.72,32.28-20.08,28.88-36.64a18,18,0,0,0-15.63-14.59c-10.28-1.4-19.14,3.57-26.76,10-16.18,13.66-29.34,30.65-44.7,45.2a359.34,359.34,0,0,1-49.33,39.08A356.65,356.65,0,0,1,638.08,303c-35.77,14.83-90.88,29.56-123.22-.47-11.61-10.78-17.61-26.71-18.41-42.53-1.07-21.19,4.41-54.95,30-59.28,36.67-6.2,78.65,49.05,86.38,79.36,8.2,32.14-5.44,70.78-35.75,84.26-28.8,12.81-63.93,0-85.8-22.72-23.52-24.41-18.59-55.9-36.07-82.56-16-24.39-41.3-23.5-66.77-24.62" > </path> </g> </g> </svg> Gradient animation option Instead of filling with color as the length of the curve increases, a gradient will perform this function <svg id="fil" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 783.53 362"> <defs> <style> .cls-3{ fill: none; stroke-miterlimit:10; stroke-width:3px; stroke:#E7E7E7; } #base { fill: none; stroke:url(#light); stroke-width:3px; stroke-dashoffset:1732; stroke-dasharray:1732; animation: fillStroke 10s linear forwards; } #keyframes fillStroke { to {stroke-dashoffset:0;} } </style> <linearGradient id="light" x1="100%" y1="100%"> <stop offset="50%" stop-color="#CF4B59"> <!-- <animate attributeName="stop-color" from="#CF4B59" to="#3E3E3E" dur="10s" fill="freeze" /> --> </stop> <stop offset="100%" stop-color="#3E3E3E"> <!-- <animate attributeName="stop-color" to="#CF4B59" from="#3E3E3E" dur="10s" fill="freeze" /> --> </stop> </linearGradient> </defs> <g transform="translate(-352.32 -8.93)"> <path class="cls-3" d="M656.89,8.93c0,48,7.42,124.9,64.45,125.92a115.56,115.56,0,0,0,53.83-12.28c8.35-4.2,16.35-9.59,21.84-17.15s8.15-17.62,5.25-26.51c-3.12-9.53-12.16-16.28-21.87-18.83-61.57-16.19-142.83,57.7-139.63,119.4,1.23,23.69,16.72,41.59,37.61,51.29,27,12.55,60.55,13.36,89.45,8.06,12.25-2.25,25.82-5.25,37.26-10.44,12.63-5.72,32.28-20.08,28.88-36.64a18,18,0,0,0-15.63-14.59c-10.28-1.4-19.14,3.57-26.76,10-16.18,13.66-29.34,30.65-44.7,45.2a359.34,359.34,0,0,1-49.33,39.08A356.65,356.65,0,0,1,638.08,303c-35.77,14.83-90.88,29.56-123.22-.47-11.61-10.78-17.61-26.71-18.41-42.53-1.07-21.19,4.41-54.95,30-59.28,36.67-6.2,78.65,49.05,86.38,79.36,8.2,32.14-5.44,70.78-35.75,84.26-28.8,12.81-63.93,0-85.8-22.72-23.52-24.41-18.59-55.9-36.07-82.56-16-24.39-41.3-23.5-66.77-24.62" /> <g class="cls-2"> <path id="base" d="M656.89,8.93c0,48,7.42,124.9,64.45,125.92a115.56,115.56,0,0,0,53.83-12.28c8.35-4.2,16.35-9.59,21.84-17.15s8.15-17.62,5.25-26.51c-3.12-9.53-12.16-16.28-21.87-18.83-61.57-16.19-142.83,57.7-139.63,119.4,1.23,23.69,16.72,41.59,37.61,51.29,27,12.55,60.55,13.36,89.45,8.06,12.25-2.25,25.82-5.25,37.26-10.44,12.63-5.72,32.28-20.08,28.88-36.64a18,18,0,0,0-15.63-14.59c-10.28-1.4-19.14,3.57-26.76,10-16.18,13.66-29.34,30.65-44.7,45.2a359.34,359.34,0,0,1-49.33,39.08A356.65,356.65,0,0,1,638.08,303c-35.77,14.83-90.88,29.56-123.22-.47-11.61-10.78-17.61-26.71-18.41-42.53-1.07-21.19,4.41-54.95,30-59.28,36.67-6.2,78.65,49.05,86.38,79.36,8.2,32.14-5.44,70.78-35.75,84.26-28.8,12.81-63.93,0-85.8-22.72-23.52-24.41-18.59-55.9-36.07-82.56-16-24.39-41.3-23.5-66.77-24.62" > </path> </g> </g> </svg>
SMIL animation doesn't work on a use element on Firefox
Although this animation is working on Chrome, Safary and Opera, it doesn't work on Firefox when I'm using the group: svg { max-width: 90vh; stroke-linecap: round; display:block; position:absolute; margin:auto; top:0;bottom:0;left:0;right:0; } path { stroke: black; stroke-width: 0.2; fill: none; } circle { fill: black; } <svg id="svg" viewBox="-50 -50 100 100"> <g id="slice"> <path d="M8.390747629378028, 4.0407710911278985Q16.337096335644915,1.578047643071413 28.72564510652592,5.067456639486153Q41.114193877406926,8.556865635900893 22.230907302700192,4.260374440788638Q3.3476207279934576,-0.03611675432361651 21.46226478304126,-6.962030472005244Q39.57690883808906,-13.887944189686872 31.396381359458864,-2.1315394650039874Q23.215853880828664,9.624865259678897 22.336451060888443,2.1742972246208847Q21.457048240948225, -5.276270810437127, 8.390747629378028, -4.0407710911278985" id="theCurve"></path> <circle r="1"> <animateMotion begin="0s" dur="10s" repeatCount="indefinite"> <mpath xlink:href="#theCurve"></mpath> </animateMotion> </circle> </g> <use xlink:href="#slice" transform="rotate(200)"></use> </svg>
This was fixed very recently. You can use a Nightly in the meantime or just wait till September's release of Firefox 69.
In order to make it work I'm putting the used path and the animated circle in a group and I'm rotating the group: svg { border:1px solid; max-width: 90vh; stroke-linecap: round; display:block; position:absolute; margin:auto; top:0;bottom:0;left:0;right:0; } path { stroke: black; stroke-width: 0.2; fill: none; } circle { fill: black; } <svg id="svg" viewBox="-50 -50 100 100"> <defs> <path d="M8.390747629378028, 4.0407710911278985Q16.337096335644915,1.578047643071413 28.72564510652592,5.067456639486153Q41.114193877406926,8.556865635900893 22.230907302700192,4.260374440788638Q3.3476207279934576,-0.03611675432361651 21.46226478304126,-6.962030472005244Q39.57690883808906,-13.887944189686872 31.396381359458864,-2.1315394650039874Q23.215853880828664,9.624865259678897 22.336451060888443,2.1742972246208847Q21.457048240948225, -5.276270810437127, 8.390747629378028, -4.0407710911278985" id="theCurve"></path> </defs> <g transform="rotate(0)"> <use xlink:href="#theCurve" ></use> <circle r="1"> <animateMotion begin="0s" dur="10s" repeatCount="indefinite"> <mpath xlink:href="#theCurve"></mpath> </animateMotion> </circle> </g> <g transform="rotate(200)"> <use xlink:href="#theCurve" ></use> <circle r="1"> <animateMotion begin="0s" dur="10s" repeatCount="indefinite"> <mpath xlink:href="#theCurve"></mpath> </animateMotion> </circle> </g> </svg>
Laggy animation on Firefox
I've replicated this effect using mask and filter. This is what I've done: Applied two masks on two different text elements, one on the left for the blurred text and one on the right for the normal text. Animated both masks and the ellipse to get the final effect. Everything works fine, however the animation is lagging on Firefox. Is there any way to make the animation smooth? CodePen body, html { height: 100%; margin: 0; background: -webkit-radial-gradient(center, ellipse, #300 10%, #000 100%); background: -moz-radial-gradient(center, ellipse, #300 10%, #000 100%); background: radial-gradient(center, ellipse, #300 10%, #000 100%); } svg { position: relative; width: 100%; left: 50%; top: 50%; transform: translate(-50%, -50%); } <svg width="100%" height="200" viewBox="0 0 700 200"> <defs> <filter id="blur"> <feGaussianBlur in="SourceGraphic" stdDeviation="3" /> </filter> <mask id="mask-left" maskUnits="userSpaceOnUse" x="0" y="0" width="700" height="200"> <path id="d1" d="M0,30 h0 c-35,15 -35,125 0,140 h0z" fill="white" /> <animate xlink:href="#d1" attributeType="XML" attributeName="d" from="M0,30 h0 c-35,15 -35,125 0,140 h-0z" to="M0,30 h700 c-35,15 -35,125 0,140 h-700z" dur="10s" repeatCount="indefinite" /> </mask> <mask id="mask-right" maskUnits="userSpaceOnUse" x="0" y="0" width="700" height="200"> <path id="d2" d="M700,30 h-672 c-35,15 -35,125 0,140 h672z" fill="white" /> <animate xlink:href="#d2" attributeType="XML" attributeName="d" from="M700,30 h-700 c-35,15 -35,125 0,140 h700z" to="M700,30 h0 c-35,15 -35,125 0,140 h0z" dur="10s" repeatCount="indefinite" /> </mask> </defs> <text mask="url(#mask-right)" x="350" y="120" fill="white" text-anchor="middle" font-size="50" font-family="Ubuntu">Magic of Filter and Masking</text> <text mask="url(#mask-left)" filter="url(#blur)" x="350" y="120" fill="white" text-anchor="middle" font-size="50" font-family="Ubuntu">Magic of Filter and Masking</text> <ellipse id="e" cx="26" cy="100" rx="25" ry="70" fill="none" stroke="#600" stroke-width="2" /> <animate xlink:href="#e" attributeType="XML" attributeName="cx" from="0" to="700" dur="10s" repeatCount="indefinite" /> </svg>
I have taken a look at your svg animation in different browsers. But it works without any lagging in FireFox and Chrome, but in Internet Explorer it's not working at all. Maybe make use of Fakesmile, this is supported for Internet Explorer.