Skip to content

Commit

Permalink
fix: sliver layout child boundingClientRect offset error
Browse files Browse the repository at this point in the history
  • Loading branch information
burtonsun authored and andycall committed Dec 16, 2023
1 parent 074f2b2 commit 64cd037
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions webf/lib/src/dom/sliver_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,20 @@ class RenderSliverRepaintProxy extends RenderProxyBox {
}
}
}

void applyLayoutTransform(RenderObject child, Matrix4 transform, bool excludeScrollOffset) {
assert(child.parent == this);
assert(parentData is SliverMultiBoxAdaptorParentData);
assert(parent is WebFRenderSliverList);

SliverConstraints grandParentConstraints = (parent as WebFRenderSliverList).constraints;
Offset offset;
double? value = (parentData as SliverMultiBoxAdaptorParentData).layoutOffset;
if(grandParentConstraints.axisDirection == AxisDirection.right) {
offset = Offset(value ?? 0, 0);
} else {
offset = Offset(0, value ?? 0);
}
transform.translate(offset.dx, offset.dy);
}
}
2 changes: 2 additions & 0 deletions webf/lib/src/rendering/box_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Offset getLayoutTransformTo(RenderObject current, RenderObject ancestor, {bool e
// Apply the layout transform for renderBoxModel and fallback to paint transform for other renderObject type.
if (parentRenderer is RenderBoxModel) {
offset += parentRenderer.obtainLayoutTransform(childRenderer, excludeScrollOffset);
} else if (parentRenderer is RenderSliverRepaintProxy) {
parentRenderer.applyLayoutTransform(childRenderer, transform, excludeScrollOffset);
} else if (parentRenderer is RenderBox) {
assert(childRenderer.parent == parentRenderer);
if (childRenderer.parentData is BoxParentData) {
Expand Down

0 comments on commit 64cd037

Please sign in to comment.