Skip to content

Commit

Permalink
fixup! TF-3246 Fix PDF viewer scrollbar not working
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Dec 16, 2024
1 parent 2cc75a0 commit 8e47e6d
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,18 @@ class _PDFViewerState extends State<PDFViewer> {
List<Rect> pageRects,
PdfViewerController controller,
) {
if (pageRects.isEmpty) {
return null;
}

if (pageRects.first.top == visibleRect.top) {
return 1; // view at top
}

if (pageRects.last.bottom == visibleRect.bottom) {
return pageRects.length; // view at bottom
}

final intersectRatios = <double>[];
for (var i = 0; i < pageRects.length; i++) {
final intersect = pageRects[i].intersect(visibleRect);
Expand All @@ -321,7 +333,7 @@ class _PDFViewerState extends State<PDFViewer> {
intersectRatios.add(intersectRatio);
}
final maxIntersectRatio = intersectRatios.reduce(max);
return intersectRatios.lastIndexOf(maxIntersectRatio) + 1;
return intersectRatios.indexOf(maxIntersectRatio) + 1;
}

void _closeView() {
Expand Down

0 comments on commit 8e47e6d

Please sign in to comment.