Я понимаю, что requestAnimationFrame() очень полезен при запуске анимации, свойство стиля которой постоянно меняется с течением времени.
const e = document.getElementById('e');
let count = 0;
function move(timestamp) {
e.style.left = ++count + 'px';
requestAnimationFrame(move);
};
requestAnimationFrame(move);
Теперь мой вопрос: Имеет ли смысл обернуть все, что меняет внешний вид представления, в requestAnimationFrame?
Другими словами, будет ли этот пример псевдокода иметь лучшую производительность, чем без него? requestAnimationFrame?
const e = document.getElementById('e');
let f = document.createDocumentFragment();
nodes.forEach((node, index) => {
f.appendChild(node);
}
requestAnimationFrame(timestamp => {
e.classList.toggle('active');
container.classList.add('active');
container.appendChild(fragment);
});
Подробнее здесь: https://stackoverflow.com/questions/491 ... ationframe