How to use requestAnimationFrame inside a Class object
问题 I have a class that takes some coordinate and duration data. I want to use it to animate an svg . In more explicit terms, I want to use that data to change svg attributes over a time frame. I'm using a step function and requestAnimationFrame outside the class: function step(timestamp) { if (!start) start = timestamp var progress = timestamp - start; var currentX = parseInt(document.querySelector('#start').getAttribute('cx')); var moveX = distancePerFrame(circleMove.totalFrames(), circleMove