+ 1

How to start a SVG animation with a click of a button?

this SVG animation : https://code.sololearn.com/WvdziSo2e72X/?ref=app

15th Jun 2018, 1:22 PM
Eli Ben Shimon
Eli Ben Shimon - avatar
6 Respostas
+ 2
Thats one dirty way to do so : window.onload = function() { 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); } Click on your name to start/stop the animation
15th Jun 2018, 2:32 PM
spotbot2k
spotbot2k - avatar
+ 2
I am not an expert in html, but make a function in js that starts the animation and the activate it when the btn is clicked.
15th Jun 2018, 1:26 PM
1337 H4x0r
1337 H4x0r - avatar
+ 1
with the onclick attribute
15th Jun 2018, 1:47 PM
Lexfuturorum
Lexfuturorum - avatar
+ 1
Feichtinger Andreas how?
15th Jun 2018, 1:52 PM
Eli Ben Shimon
Eli Ben Shimon - avatar
0
write a a js function that sets the repeatcounter
15th Jun 2018, 1:57 PM
Lexfuturorum
Lexfuturorum - avatar
0
Thank you, Alexander Schwirjow!!
15th Jun 2018, 3:48 PM
Eli Ben Shimon
Eli Ben Shimon - avatar