I am currently developing a Vue component for my application that serves as a countdown timer, starting from X
minutes and ending at 00:00
.
Although I understand that animating with svg
can achieve the desired effect, I lack the necessary expertise in using any svg
libraries.
The animation I need for my progress component should move smoothly along a path based on time, with nodes being added or updated accordingly.
Here is my existing countdown component:
var app = new Vue({
el: '#app',
data: {
date: moment(2 * 60 * 1000)
},
computed: {
time: function(){
return this.date.format('mm:ss');
}
},
mounted: function(){
var timer = setInterval(() => {
this.date = moment(this.date.subtract(1, 'seconds'));
if(this.date.diff(moment(0)) === 0){
clearInterval(timer);
alert('Done!');
}
}, 1000);
}
});
<script src="https://momentjs.com/downloads/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script>
<div id="app">{{ time }}</div>
Here is the svg code for the progress circle:
<svg x="0px" y="0px" viewBox="0 0 90 90">
<style type="text/css">
.st0{fill:#FFFFFF;}
.st1{fill:none;stroke:#B5B5B5;stroke-miterlimit:10;}
.st2{fill:none;stroke:#408EFF;stroke-linecap:round;stroke-miterlimit:10;}
.st3{fill:#408EFF;}
</style>
<rect class="st0" width="90" height="90"/>
<circle class="st1" cx="45" cy="45" r="40"/>
<path class="st2" d="M45,5c22.1,0,40,17.9,40,40S67.1,85,45,85S5,67.1,5,45S22.9,5,45,5"/>
<circle class="st3" cx="45" cy="5" r="3"/>
</svg>
How can I go about achieving the intended outcome?
I would greatly appreciate any assistance provided.