Skip to content

reader: fix skewed sidebar page thumbnails - #12

Open
DenizSAHIN570 wants to merge 1 commit into
uurtech:masterfrom
DenizSAHIN570:fix/sidebar-thumbnail-aspect
Open

DenizSAHIN570 wants to merge 1 commit into
uurtech:masterfrom
DenizSAHIN570:fix/sidebar-thumbnail-aspect

Conversation

@DenizSAHIN570

@DenizSAHIN570 DenizSAHIN570 commented Sep 14, 2026

Copy link
Copy Markdown

Fixes #10.

previewForPage() in Sidebar.tsx positioned elements against a hardcoded 166x247 box but never offset by the page's actual margins/header height, so x=0,y=0 rendered at the page's top-left corner instead of the content area's top-left corner — which is what position 0,0 actually means (see how PageRenderer insets its content div by margins.left/margins.top + headerHeight). Elements ended up compressed and flush against the top-left edge instead of properly inset.

Now computes real page dimensions via getPageDimensions() (same helper PageRenderer uses) and applies the same margin/header offset, so the thumbnail matches what the page actually renders. Also made the thumbnail box's aspect ratio track the page's real size/orientation instead of a hardcoded 210/297, so non-A4 pages don't skew either.

Note: these thumbnails are an abstract wireframe (generic colored bars per element type), not a real scaled render of the page — this PR only fixes their positioning/aspect within that existing design.

Tested against docs/examples/article.jdf (the doc from the linked issue's screenshot) — confirmed the stray disconnected line is gone and content is properly inset now.

previewForPage() positioned elements against a hardcoded 166x247 content
box, but never offset by the page's actual margins/header height - so
every element rendered as if x=0,y=0 meant the page's top-left corner
instead of the content area's top-left corner (which is where position:0,0
actually is, per PageRenderer). Elements ended up compressed and flush
against the top-left edge instead of properly inset.

Now computes real page dimensions via getPageDimensions() (mirrors
PageRenderer) and offsets each element by margins.left / (margins.top +
headerHeight), matching how the page actually renders. Also fixed the
thumbnail box's aspect ratio to track the page's real size/orientation
instead of a hardcoded 210/297, so non-A4 pages don't skew either.

Fixes uurtech#10
@DenizSAHIN570
DenizSAHIN570 force-pushed the fix/sidebar-thumbnail-aspect branch from cebf404 to d00c719 Compare September 14, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar page thumbnails render skewed/misaligned (wrong aspect ratio)

1 participant