자바스크립트로 스타일을 변경한다면 rAF(requestAnimationFrame)를 사용해보세요!
현우
const executeAnimation = () => {
// ... script
}
setInterval(executeAnimation, 1000 / 60);
const executeAnimation = () => {
setTimeout(executeAnimation, 1000 / 60);
}
setTimeout(executeAnimation, 1000 / 60);const executeAnimation = () => {
...any script
requestAnimationFrame(executeAnimation);
}
requestAnimationFrame(executeAnimation);let startTime;
const draw = (timestamp) => {
if (!start) start = timestamp;
currentTime = timestamp - startTime;
if (currentTime > 2000) {
console.log('The End');
return;
}
requestAnimationFrame(draw);
};
requestAnimationFrame(draw);