-
Notifications
You must be signed in to change notification settings - Fork 991
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Have you checked for an existing issue?
- I have searched the existing issues
Use case
Currently, when the cursor moves below the keyboard, QuillEditor automatically triggers scrolling to make the content visible. However, I want to customize the scrolling behavior, for example, triggering automatic scrolling when the cursor moves to just below the center of the screen. This would create more space between the input position and the keyboard. Are there any better methods to achieve this?
Proposal
Attached is the internal implementation:
void _showCaretOnScreen() {
if (!widget.config.showCursor || _showCaretOnScreenScheduled) {
return;
}
_showCaretOnScreenScheduled = true;
SchedulerBinding.instance.addPostFrameCallback((_) {
if (widget.config.scrollable && _scrollController.hasClients) {
_showCaretOnScreenScheduled = false;
if (!mounted) {
return;
}
final viewport = RenderAbstractViewport.of(renderEditor);
final editorOffset =
renderEditor.localToGlobal(const Offset(0, 0), ancestor: viewport);
final offsetInViewport = _scrollController.offset + editorOffset.dy;
final offset = renderEditor.getOffsetToRevealCursor(
_scrollController.position.viewportDimension,
_scrollController.offset,
offsetInViewport,
);
final viewportHeight = scrollController.position.viewportDimension;
if (offset != null) {
if (_disableScrollControllerAnimateOnce) {
_disableScrollControllerAnimateOnce = false;
return;
}
_scrollController.animateTo(
math.min(offset, _scrollController.position.maxScrollExtent),
duration: const Duration(milliseconds: 100),
curve: Curves.fastOutSlowIn,
);
}
}
});
}
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request