Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

性能调优,将获取offsetwidth的行为放置requestAnimationFrame中 #395

Merged
merged 7 commits into from Jun 17, 2019

Conversation

zzzJH
Copy link
Contributor

@zzzJH zzzJH commented Apr 8, 2019

这个变动的性质是

  • 其他改动

需求背景

  1. 针对使用antd表格,在大量数据下的调优
  2. 表格下的分页使用了该控件,存在forced reflow的问题
    image

实现方案和 API

将获取offsetwidth的行为放置requestAnimationFrame中

const raf = window.requestAnimationFrame
  || window.webkitRequestAnimationFrame
  || window.mozRequestAnimationFrame
  || window.msRequestAnimationFrame
  || function(cb) { return setTimeout(cb, 16); };

function componentDidMount() {
  raf(this.setDropdownWidth);
}

function componentDidUpdate() {
  raf(this.setDropdownWidth);
}

对用户的影响和可能的风险

无明显影响

changelog

性能优化,将获取offsetwidth的行为放置requestAnimationFrame中

请求合并前的自查清单

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

后续计划

背景:针对表格大量数据下调优,表格下的分页控件使用了改控件
优化:将获取offsetwidth的行为放置raf中
@ant-design-bot
Copy link

ant-design-bot commented Apr 8, 2019

Deploy preview for rc-select failed.

Built with commit adc6ef3

https://app.netlify.com/sites/rc-select/deploys/5cac9034a77bb500097e0652

@afc163
Copy link
Member

afc163 commented Apr 8, 2019

👍!

src/SelectTrigger.tsx Outdated Show resolved Hide resolved
@zombieJ
Copy link
Member

zombieJ commented Apr 8, 2019

raf 后要记得 cancel,否则还是都会跑一边。

另外需要测试一下,第一次弹窗的时候会不会闪一下

@afc163
Copy link
Member

afc163 commented Apr 9, 2019

这个库的 ci 怎么没了?@chenshuai2144 @zombieJ

@zzzJH
Copy link
Contributor Author

zzzJH commented Apr 9, 2019

还发现个问题,本地跑用例发现有个没过,修改之前就已经存在了。
image

src/SelectTrigger.tsx Outdated Show resolved Hide resolved
src/SelectTrigger.tsx Outdated Show resolved Hide resolved
@afc163 afc163 merged commit dcb6397 into react-component:master Jun 17, 2019
@Tsury
Copy link

Tsury commented Jun 29, 2019

I'm using v9.1.5 and I'm still seeing this issue...
https://i.imgur.com/cPv8MB3.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants