+ 2
How to start a SVG animation with a click of a button?
this SVG animation : https://code.sololearn.com/WvdziSo2e72X/?ref=app
1 Answer
0
Thats one dirty way to do so :
<script>
document.querySelector('.first').addEventListener('click', function() {
var elements = document.querySelectorAll('animate');
var repeat = 150;
if (elements[0].getAttribute('repeatCount') != 0) {
repeat = 0;
}
for (var i = 0; i < elements.length; i++) {
elements[i].setAttribute('repeatCount', repeat);
}
}, false);
</script>
Click on your name to start/stop the animation