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

chore: improve use view state perf #101

Merged
merged 1 commit into from Dec 8, 2021
Merged

Conversation

Aaaaash
Copy link
Member

@Aaaaash Aaaaash commented Dec 7, 2021

变动类型

  • 代码风格优化

需求背景和解决方案

对于手风琴面板的视图,当隐藏时 viewState 会更新为 {width:0, height: 0} ,而实际此时面板只是被隐藏(display: none),尺寸并没有真正改变,再次展示时 (display: block) 导致例如 explorer、outline 这类可能有大量列表的组件频繁触发 render
主要修改是在尺寸为 0 以及 display:block 情况下不更新 viewState,不影响实际拖拽行为

补充一个对比图,打开 vscode repo, 展开 node_modules 的情况下

viewstate-before

viewstate-after

changelog

@Aaaaash Aaaaash requested a review from ensorrow December 7, 2021 13:11
@ensorrow
Copy link
Contributor

ensorrow commented Dec 7, 2021

感觉会出现在在后台的视图不响应尺寸变化的情况,试试窗口resize一下,然后切换到隐藏的视图

@Aaaaash
Copy link
Member Author

Aaaaash commented Dec 7, 2021

感觉会出现在在后台的视图不响应尺寸变化的情况,试试窗口resize一下,然后切换到隐藏的视图

测试了一下可以,本身切换视图显示/隐藏都会触发 resize,区别就是尺寸,这里修改就是在尺寸不变的情况下不更新,而隐藏后 resize ,再次显示出来尺寸已经变了,会正常响应

Kapture 2021-12-07 at 21 54 59

@ensorrow
Copy link
Contributor

ensorrow commented Dec 7, 2021

LGTM

@Aaaaash
Copy link
Member Author

Aaaaash commented Dec 8, 2021

合了

@Aaaaash Aaaaash merged commit 4379c01 into main Dec 8, 2021
@erha19 erha19 deleted the chore/improve-use-viewstate-perf branch December 8, 2021 03:37
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

3 participants