|
|
|
@ -63,7 +63,9 @@ mixin RawEditorStateSelectionDelegateMixin on EditorState |
|
|
|
|
final localRect = renderEditor.getLocalRectForCaret(position); |
|
|
|
|
final targetOffset = _getOffsetToRevealCaret(localRect, position); |
|
|
|
|
|
|
|
|
|
if (scrollController.hasClients) { |
|
|
|
|
scrollController.jumpTo(targetOffset.offset); |
|
|
|
|
} |
|
|
|
|
renderEditor.showOnScreen(rect: targetOffset.rect); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -77,7 +79,9 @@ mixin RawEditorStateSelectionDelegateMixin on EditorState |
|
|
|
|
// `renderEditable.preferredLineHeight`, before the target scroll offset is |
|
|
|
|
// calculated. |
|
|
|
|
RevealedOffset _getOffsetToRevealCaret(Rect rect, TextPosition position) { |
|
|
|
|
if (!scrollController.position.allowImplicitScrolling) { |
|
|
|
|
// Make sure scrollController is attached |
|
|
|
|
if (scrollController.hasClients && |
|
|
|
|
!scrollController.position.allowImplicitScrolling) { |
|
|
|
|
return RevealedOffset(offset: scrollController.offset, rect: rect); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -102,12 +106,17 @@ mixin RawEditorStateSelectionDelegateMixin on EditorState |
|
|
|
|
|
|
|
|
|
// No overscrolling when encountering tall fonts/scripts that extend past |
|
|
|
|
// the ascent. |
|
|
|
|
final targetOffset = (additionalOffset + scrollController.offset).clamp( |
|
|
|
|
var targetOffset = additionalOffset; |
|
|
|
|
if (scrollController.hasClients) { |
|
|
|
|
targetOffset = (additionalOffset + scrollController.offset).clamp( |
|
|
|
|
scrollController.position.minScrollExtent, |
|
|
|
|
scrollController.position.maxScrollExtent, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final offsetDelta = scrollController.offset - targetOffset; |
|
|
|
|
final offsetDelta = |
|
|
|
|
(scrollController.hasClients ? scrollController.offset : 0) - |
|
|
|
|
targetOffset; |
|
|
|
|
return RevealedOffset( |
|
|
|
|
rect: rect.shift(unitOffset * offsetDelta), offset: targetOffset); |
|
|
|
|
} |
|
|
|
|