JSFiddle - React, Tailwind, and code Playground
HTML
<svg width="350" height="350">
<g id="myImage">
<rect id="mySquare" x="150" y="150" width="20" height="20" fill="blue" />
</g>
</svg>
<input id="speed" type="text" value="10" />
<button id="start" onclick="startAnimation();">
start
</button>
JavaScript
var squareShape;
var myTimer;
function startAnimation() {
squareShape = document.getElementById("mySquare");
var speed = document.getElementById("speed"); //need to add this variable as well
squareShape.currentTheta = 0;
myTimer = setInterval(animateImage, speed.value);
//myTimer.Interval(speed.value);
animateImage();
}
function animateImage() {
squareShape.setAttribute("transform", "rotate(" + squareShape.currentTheta + ")");
squareShape.currentTheta += 1.5;
}