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

fix: percentage of positioned element #1044

Merged
merged 8 commits into from
Jan 6, 2022

Conversation

temper357
Copy link
Contributor

Closes #1042

  1. transform: translate() 百分比,如 transform: translateX(50%)

此 issue 原因是 transform 的 getter 中为了提升性能(transformMatrix 计算有耗费性能)会缓存上一次计算结果,而百分比是相对自身 size 计算,需要等自身 layout 完才能出来,因此在 layout 之前不能使用默认值 0,而需要使用 null 防止缓存生效。另外对于 transform, background-size, border-radius 这些在 paint 阶段计算的 css 属性 paint 时肯定能拿到自身 size,因此 markParentNeedsLayout 这个操作是多余的。

  1. 容器未设置高度,top/bottom 配置百分比失效,如 position: fixed; bottom: 50%;

此 issue 原因是在 length.dart 中解析 percentage 时错误地使用了 parent 的 renderStyle,正确应该使用 containing block 的 renderStyle,也就是 renderBoxModel 的直接 parent 对应的 renderStyle。

@temper357 temper357 changed the title [WIP] fix: percentage of positioned element fix: percentage of positioned element Jan 4, 2022
answershuto
answershuto previously approved these changes Jan 6, 2022
@answershuto answershuto merged commit 7317ada into main Jan 6, 2022
@answershuto answershuto deleted the fix/percentage-of-positioned-element branch January 6, 2022 11:34
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.

position 为 absolute/fixed 时百分比失效 case
3 participants