update: reflow

This commit is contained in:
qianguyihao
2021-01-19 21:23:49 +08:00
parent 0c3df74022
commit a06e66c726
2 changed files with 51 additions and 25 deletions

View File

@@ -11,3 +11,17 @@
关于浏览器的渲染机制可以看本教程的另外一篇文章
> 前端面试/面试必看/浏览器渲染机制.md
## 避免布局抖动layout thrashing
1尽量避免 reflow
比如说如果想改变一个元素的位置很多人可能会使用相对布局的lefttop属性但是这个属性会引起 reflow我们可以使用 `transfrom:translate`让元素做位移这个属性既不会触发 reflow也不会触发 repaint只会触发 conmposite
再比如说vuereact这样的框架采用了虚拟DOM它会把涉及到DOM修改的操作积攒起来然后统一计算批量处理最后应用到真正的DOM上
2读写分离
## 使用FastDom 做防抖