-
Notifications
You must be signed in to change notification settings - Fork 18
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
[BUG] [Mobile] [Web] Jump to the bottom of next page when scrolling forward #1634
Comments
The problem is we need to know the position (in px) of the item at index 0 before scrolling forward. This way when new items will be inserted starting from this index, the UI won't move. I tried with Solution found here: EdsonBueno/infinite_scroll_pagination#56 (comment) |
I also tried with a custom scroll physic, but I'm struggling a bit to find the good way to calculate the good position to keep since every item can have a different size. See this branch: https://github.com/linagora/twake-on-matrix/tree/TW-1634/custom_scroll_physics import 'package:flutter/material.dart';
class PositionRetainedScrollPhysics extends ScrollPhysics {
final bool shouldRetain;
const PositionRetainedScrollPhysics(
{ScrollPhysics? parent, this.shouldRetain = true})
: super(parent: parent);
@override
PositionRetainedScrollPhysics applyTo(ScrollPhysics? ancestor) {
return PositionRetainedScrollPhysics(
parent: buildParent(ancestor),
shouldRetain: shouldRetain,
);
}
@override
double adjustPositionForNewDimensions({
required ScrollMetrics oldPosition,
required ScrollMetrics newPosition,
required bool isScrolling,
required double velocity,
}) {
final position = super.adjustPositionForNewDimensions(
oldPosition: oldPosition,
newPosition: newPosition,
isScrolling: isScrolling,
velocity: velocity,
);
final diff = newPosition.maxScrollExtent - oldPosition.maxScrollExtent;
if (oldPosition.pixels == 0 && newPosition.pixels == 0) {
if (newPosition.maxScrollExtent > oldPosition.maxScrollExtent &&
diff > 0 &&
shouldRetain) {
return diff;
} else {
return position;
}
} else {
return position;
}
}
} |
removing this ticket from |
Reproduce steps:
Actual:
Jump to the bottom of next page, so the user has to scroll backward to continue where he left
Expected:
Next page loads without moving the scroll position
Capture.video.du.27-03-2024.06.41.10.webm
screen-20240327-070619.mp4
The text was updated successfully, but these errors were encountered: