J
J
Joirvy2019-06-06 02:10:58
JavaScript
Joirvy, 2019-06-06 02:10:58

How to change SVG image using js?

I have an SVG image and I need an animation for a countdown timer. I want to make this circle shorter by 1/60 every second.

<svg viewBox="0 0 200 200" preserveAspectRatio="none" class="progress-seconds">
<circle cx="100" stroke-dasharray="0 0" cy="100" r="42" id="progress-seconds" fill="none" stroke="#ff7323" stroke-width="10" transform="rotate(-90,100,100)"></circle>
</svg>

https://jsfiddle.net/xzngybuj/1/
What value of the svg file needs to be changed for this and how to calculate the proportions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rustam Bainazarov, 2019-06-06
@BeatTimy

CSS is enough here (stroke-dashoffset animation), JS in this example is only responsible for displaying the value of the counter inside the circle:
Original:
https://codepen.io/zebateira/pen/VvqJwm
Search query:
https://www.google.com/search?q=svg+timer+circle&o...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question