-
Notifications
You must be signed in to change notification settings - Fork 457
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
SliverVisibiltyDetector should consider SliverConstraints overlap #507
Comments
I currently fix its manually by creating a OverlayRenderVisibilityDetectorBase with patched code in _determineVisibility method of RenderVisibilityDetectorBase mixin OverlayRenderVisibilityDetectorBase on RenderSliver{
//...skipping some code
//...
VisibilityInfo _determineVisibility(ContainerLayer? layer, Rect bounds) {
//...skipping some code
//...
var info = VisibilityInfo.fromRects(
key: key,
widgetBounds: MatrixUtils.transformRect(transform, bounds),
clipRect: clip,
);
switch (applyGrowthDirectionToAxisDirection(
constraints.axisDirection,
constraints.growthDirection,
)) {
case AxisDirection.down:
info = VisibilityInfo(
key: info.key,
size: info.size,
visibleBounds: Rect.fromLTRB(info.visibleBounds.left, info.visibleBounds.top + constraints.overlap,
info.visibleBounds.right, info.visibleBounds.bottom),
);
if (info.visibleBounds.height <= 0) {
return VisibilityInfo(
key: key,
size: info.size,
);
}
break;
case AxisDirection.up:
info = VisibilityInfo(
key: info.key,
size: info.size,
visibleBounds: Rect.fromLTRB(info.visibleBounds.left, info.visibleBounds.top, info.visibleBounds.right,
info.visibleBounds.bottom - constraints.overlap),
);
if (info.visibleBounds.height <= 0) {
return VisibilityInfo(
key: key,
size: info.size,
);
}
break;
case AxisDirection.right:
info = VisibilityInfo(
key: info.key,
size: info.size,
visibleBounds: Rect.fromLTRB(info.visibleBounds.left + constraints.overlap, info.visibleBounds.top,
info.visibleBounds.right, info.visibleBounds.bottom),
);
if (info.visibleBounds.width <= 0) {
return VisibilityInfo(
key: key,
size: info.size,
);
}
break;
case AxisDirection.left:
info = VisibilityInfo(
key: info.key,
size: info.size,
visibleBounds: Rect.fromLTRB(info.visibleBounds.left, info.visibleBounds.top,
info.visibleBounds.right - constraints.overlap, info.visibleBounds.bottom),
);
if (info.visibleBounds.width <= 0) {
return VisibilityInfo(
key: key,
size: info.size,
);
}
break;
}
return info;
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem description
visibility_detector
version: 0.4.0+2
SliverVisibiltyDetector should consider SliverConstraints overlap data to made its more reliable within sliver scroll view.
Steps to reproduce
https://zapp.run/edit/flutter-zj80065pj810
Code
Expected behavior
It should able to detected the overlap from other sliver with SliverConstraints.
Actual behavior
Its only detected if a sliver visible within sliver scroll view
Environment
Windows 10
flutter 3.2.0
The text was updated successfully, but these errors were encountered: