Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

change relayout for horizontal scroll #109

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions lib/pdf_render_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1287,10 +1287,9 @@ class PdfViewerState extends State<PdfViewer>

/// Default page layout logic that layouts pages vertically or horizontally.
void _relayoutDefault(Size viewSize) {
final maxWidth = _pages!.fold<double>(0.0, (maxWidth, page) => max(maxWidth, page.pageSize.width));
final ratio = (viewSize.width - _padding * 2) / maxWidth;
if (widget.params?.scrollDirection == Axis.horizontal) {
final maxHeight = _pages!.fold<double>(
0.0, (maxHeight, page) => max(maxHeight, page.pageSize.height));
final ratio = (viewSize.height - _padding * 2) / maxHeight;
var left = _padding;
for (int i = 0; i < _pages!.length; i++) {
final page = _pages![i];
Expand All @@ -1299,11 +1298,8 @@ class PdfViewerState extends State<PdfViewer>
page.rect = Rect.fromLTWH(left, _padding, w, h);
left += w + _padding;
}
_docSize = Size(left, viewSize.height);
_docSize = Size(left, _pages!.first.pageSize.height*ratio + 10);
} else {
final maxWidth = _pages!.fold<double>(
0.0, (maxWidth, page) => max(maxWidth, page.pageSize.width));
final ratio = (viewSize.width - _padding * 2) / maxWidth;
var top = _padding;
for (int i = 0; i < _pages!.length; i++) {
final page = _pages![i];
Expand Down