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 the sliver with positioned element usage problem. #1341

Merged
merged 19 commits into from
Apr 27, 2022
Merged

Conversation

wssgcg1213
Copy link
Member

@wssgcg1213 wssgcg1213 commented Apr 21, 2022

  • 修复 sliver 元素内如果有 positioned 元素,首帧创建时报错导致不显示的问题
  • 修复 sliver 元素内如果有 positioned 元素,该元素的 RenderPositionPlaceholder 滚动到销毁位置时,不应该同时销毁定位的元素的问题

@wssgcg1213 wssgcg1213 changed the title fix: reduce img element memory usage, fix the sliver with fixed eleme… Fix the sliver with fixed element usage problem. Apr 22, 2022

// Ignore the fixed element to unmount render object.
// It's useful for sliver manager to unmount child render object, but excluding fixed elements.
if (keepFixedAlive && _isFixed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里要不要考虑相对于 sliver layout 的 ancestor 定位的 absolute element 的 case

Copy link
Member Author

@wssgcg1213 wssgcg1213 Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

display sliver 的节点本身需要被视为一个 containing block

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果是这样的话,在 element 中 _findContainingBlock 中应该要加上 sliver 的判断逻辑

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有个问题, RenderSliverListLayout 并不会 添加这个 child, 也不会给它布局或者绘制

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样的话, 一旦设置 absolute, 这个元素就不见了

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方要不先记一个 issue 吧, 暂时不太好解决

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

或者规则定成 sliver item 是 containing block 更合理些

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

恩, 听起来可以

@answershuto
Copy link
Member

冲突了

@wssgcg1213 wssgcg1213 changed the title Fix the sliver with fixed element usage problem. Fix the sliver with positioned element usage problem. Apr 26, 2022
@openkraken openkraken deleted a comment from answershuto Apr 26, 2022
yuanyan
yuanyan previously approved these changes Apr 27, 2022
}

void _scrollYListener() {
assert(scrollListener != null);
scrollListener!(scrollOffsetY!.pixels, AxisDirection.down);
markNeedsPaint();
if (scrollOffsetY != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 scrollOffsetY 为 null 是不是应该断言?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

滚动惯性过程中 节点可能解挂, 但是这个回调还在触发, 要到下一帧才会销毁

@wssgcg1213 wssgcg1213 merged commit eb8d7e5 into main Apr 27, 2022
@wssgcg1213 wssgcg1213 deleted the fix/sliver-usage branch April 27, 2022 11:58
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.

4 participants