Skip to content

Commit

Permalink
feat: customize auto scroll offset on mobile (AppFlowy-IO#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 authored Mar 14, 2024
1 parent ecec65f commit 2493d9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lib/src/editor/editor_component/service/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import 'package:provider/provider.dart';
// the operation must be paired
KeepEditorFocusNotifier keepEditorFocusNotifier = KeepEditorFocusNotifier();

/// The default value of the auto scroll edge offset on mobile
/// The editor will scroll when the cursor is close to the edge of the screen
double appFlowyEditorAutoScrollEdgeOffset = 220.0;

class AppFlowyEditor extends StatefulWidget {
AppFlowyEditor({
super.key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,13 @@ class _ScrollServiceWidgetState extends State<ScrollServiceWidget>
if (PlatformExtension.isMobile) {
// soft keyboard
// workaround: wait for the soft keyboard to show up
return Future.delayed(
Duration(
milliseconds:
KeyboardHeightObserver.currentKeyboardHeight == 0 ? 250 : 0,
), () {
final duration = KeyboardHeightObserver.currentKeyboardHeight == 0
? const Duration(milliseconds: 250)
: Duration.zero;
return Future.delayed(duration, () {
startAutoScroll(
endTouchPoint,
edgeOffset: 150,
edgeOffset: appFlowyEditorAutoScrollEdgeOffset,
duration: Duration.zero,
);
});
Expand Down

0 comments on commit 2493d9b

Please sign in to comment.