Skip to content

Commit

Permalink
fix: side effects of itemscrollcontroller jumpto
Browse files Browse the repository at this point in the history
  • Loading branch information
richardshiue committed Jan 14, 2025
1 parent 5352bb4 commit d59c551
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,24 @@ class EditorScrollController {
);
}

final index = offset.toInt();
int index = max(0, offset.toInt());
final (start, end) = visibleRangeNotifier.value;
if (index < start || index > end) {
itemScrollController.jumpTo(
index: max(0, index),
alignment: 0.5,
);

if (start <= index && index <= end) {
return;
}

double alignment = 0.5;
if (index == 0) {
alignment = 0.0;
} else if (index == editorState.document.root.children.length - 1) {

Check warning on line 203 in lib/src/editor/editor_component/service/scroll/editor_scroll_controller.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/editor_component/service/scroll/editor_scroll_controller.dart#L203

Added line #L203 was not covered by tests
alignment = 1.0;
}

itemScrollController.jumpTo(
index: index,
alignment: alignment,
);
}

void jumpToTop() {
Expand Down

0 comments on commit d59c551

Please sign in to comment.