Animate Plus Annotation
源码阅读/注释
animateplus 是一个专注于性能和创作灵活性、提供稳定60 FPS的迷你 JavaScript 动画库。分析其源码有助于从中学习一些优化制作动画的技巧
一些干货
取数组第一个元素
一般会写
const first = (array) => array[0];
而 animateplus 是这样写的
const first = ([item]) => item;
使用 reduce 为元素设置属性
Object.entries(attributes).reduce((node, [attribute, value]) => {
node.setAttribute(attribute, value);
return node; // 返回 node 供下一次遍历使用
}, document.creat