fix: scrolling issue with single block node from bottom to top (#1148)

This commit is contained in:
Morn 2025-10-28 10:16:00 +08:00 • committed by GitHub
commit 85f0d81e50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -33,7 +33,7 @@ class _ScrollServiceWidgetState extends State<ScrollServiceWidget>
@override @override
late ScrollController scrollController = ScrollController(); late ScrollController scrollController = ScrollController();
double offset = 0; Selection? lastSelection;
@override @override
void initState() { void initState() {
@ -105,13 +105,25 @@ class _ScrollServiceWidgetState extends State<ScrollServiceWidget>
case 'MobileSelectionDragMode.leftSelectionHandle': case 'MobileSelectionDragMode.leftSelectionHandle':
targetRect = selectionRects.first; targetRect = selectionRects.first;
direction = AxisDirection.up; direction = AxisDirection.up;
break;
case 'MobileSelectionDragMode.rightSelectionHandle': case 'MobileSelectionDragMode.rightSelectionHandle':
targetRect = selectionRects.last; targetRect = selectionRects.last;
direction = AxisDirection.down; direction = AxisDirection.down;
break;
default: default:
targetRect = selectionRects.last; targetRect = selectionRects.last;
/// sometimes moving up in a long single node may be not working
/// so we need to special handle this case.
final isInSingleNode = (lastSelection?.isSingle ?? false) &&
lastSelection?.start.path == selection.start.path;
if (selection.isForward && isInSingleNode) {
targetRect = selectionRects.first;
}
} }
lastSelection = selection;
final endTouchPoint = targetRect.centerRight; final endTouchPoint = targetRect.centerRight;
if (PlatformExtension.isMobile) { if (PlatformExtension.isMobile) {

View file

@ -300,6 +300,7 @@ class EdgeDraggingAutoScroller {
scrollable.position.pixels + delta, scrollable.position.pixels + delta,
); );
} }
break;
case AxisDirection.right: case AxisDirection.right:
case AxisDirection.down: case AxisDirection.down:
if (proxyStart < viewportStart && if (proxyStart < viewportStart &&
@ -323,6 +324,7 @@ class EdgeDraggingAutoScroller {
scrollable.position.pixels + delta, scrollable.position.pixels + delta,
); );
} }
break;
} }
final double currentPixels = scrollable.position.pixels; final double currentPixels = scrollable.position.pixels;