Like svg animations? But do not know which side to approach them?
So look for libraries that implement SVG animations. Yes, this is a solution, but it is very difficult not to understand the basics of SVG animation, immediately use the library. Any error in the SVG source code will prevent the library from triggering.
Therefore, you need to understand a bit about pure SVG and smil before using libraries.
The implementation of this scenario:
Object 1 is moving. → Movement completed. → Object 2 is moving. → Movement completed ... etc.
Take an example from a question and implement a chain of sequential animations using the begin attribute
begin="start.click" - the animation will start after clicking on the 'start' buttonbegin="an_crc1.end" - the second animation will begin after the end of the first animation an_crc1begin="an_crc2.end" - the third animation will begin after the end of the second animation an_crc2
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="400" viewBox="0 0 400 400" style="border:1px solid gray;" > <g> <circle id="crc1" cx="40" cy="50" r="20" fill="crimson" > <animate id="an_crc1" attributeName="cx" values="40;350" begin="start.click" dur="1s" fill="freeze" /> </circle> <circle id="crc2" cx="40" cy="150" r="20" fill="gold" > <animate id="an_crc2" attributeName="cx" values="40;350" begin="an_crc1.end" dur="1s" fill="freeze" /> </circle> <circle id="crc3" cx="40" cy="250" r="20" fill="greenyellow" > <animate id="an_crc3" attributeName="cx" values="40;350" begin="an_crc2.end" dur="1s" fill="freeze" /> </circle> </g> <g id="start" transform="translate(100,-80)"> <rect x="45" y="85" height="24" width="60" rx="5" fill="green" /> <text x="60" y="102" font-size="18" fill="gold">Start</text> </g> </svg>
By changing the attribute parameters you can get different scenarios. For example, the first lap starts, after a delay of 1 second, two other rounds start simultaneously
begin="start.click" - the animation will start after clicking on the 'start' buttonbegin="start.click+1s" - the second animation will start after the start of the first animation with a delay of 1sbegin="start.click+1s" - the third animation will start after the start of the first animation with a delay of 1s
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="400" viewBox="0 0 400 400" style="border:1px solid gray;" > <g> <circle id="crc1" cx="40" cy="50" r="20" fill="crimson" > <animate id="an_crc1" attributeName="cx" values="40;350;40" begin="start.click" dur="2s" fill="freeze" /> </circle> <circle id="crc2" cx="40" cy="150" r="20" fill="gold" > <animate id="an_crc2" attributeName="cx" values="40;350;40" begin="start.click+1s" dur="2s" fill="freeze" /> </circle> <circle id="crc3" cx="40" cy="250" r="20" fill="greenyellow" > <animate id="an_crc3" attributeName="cx" values="40;350;40" begin="start.click+1s" dur="2s" fill="freeze" /> </circle> </g> <g id="start" transform="translate(100,-80)"> <rect x="45" y="85" height="24" width="60" rx="5" fill="green" /> <text x="60" y="102" font-size="18" fill="gold">Start</text> </g> </svg>
Looping animation
After the end of the last (third) animation, the first animation should start.
begin="start.click;an_crc3.end"
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="400" viewBox="0 0 400 400" style="border:1px solid gray;" > <g> <circle id="crc1" cx="40" cy="50" r="20" fill="crimson" > <animate id="an_crc1" attributeName="cx" values="40;350;40" begin="start.click;an_crc3.end" dur="2s" fill="freeze" /> </circle> <circle id="crc2" cx="40" cy="150" r="20" fill="gold" > <animate id="an_crc2" attributeName="cx" values="40;350;40" begin="an_crc1.end" dur="2s" fill="freeze" /> </circle> <circle id="crc3" cx="40" cy="250" r="20" fill="greenyellow" > <animate id="an_crc3" attributeName="cx" values="40;350;40" begin="an_crc2.end" dur="2s" fill="freeze" /> </circle> </g> <g id="start" transform="translate(100,-80)"> <rect x="45" y="85" height="24" width="60" rx="5" fill="green" /> <text x="60" y="102" font-size="18" fill="gold">Start</text> </g> </svg>