Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion test/integration/reorganize_pages_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@ describe("Reorganize Pages View", () => {
"page_with_number.pdf",
"#viewsManagerToggleButton",
"page-fit",
null,
{
appSetup: () => {
document
.getElementById("thumbnailsView")
.style.setProperty("--thumbnail-width", "26px");
},
},
{ enableSplitMerge: true }
);
});
Expand Down
9 changes: 7 additions & 2 deletions web/pdf_thumbnail_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { AppOptions } from "./app_options.js";

const DRAW_UPSCALE_FACTOR = 2; // See comment in `PDFThumbnailView.draw` below.
const MAX_NUM_SCALING_STEPS = 3;
const THUMBNAIL_WIDTH = 126; // px

/**
* @typedef {Object} PDFThumbnailViewOptions
Expand Down Expand Up @@ -80,6 +79,8 @@ class TempImageFactory {
class PDFThumbnailView extends RenderableView {
#renderingState = RenderingStates.INITIAL;

static #baseWidth = 0;

/**
* @param {PDFThumbnailViewOptions} options
*/
Expand Down Expand Up @@ -152,6 +153,10 @@ class PDFThumbnailView extends RenderableView {
container.append(thumbnailContainer);
}

static setThumbnailBaseWidth(width) {
this.#baseWidth ||= width;
}

clone(container, id) {
const thumbnailView = new PDFThumbnailView({
container,
Expand Down Expand Up @@ -240,7 +245,7 @@ class PDFThumbnailView extends RenderableView {
const { width, height } = this.viewport;
const ratio = width / height;

const canvasWidth = (this.canvasWidth = THUMBNAIL_WIDTH);
const canvasWidth = (this.canvasWidth = PDFThumbnailView.#baseWidth);
const canvasHeight = (this.canvasHeight = (canvasWidth / ratio) | 0);
this.scale = canvasWidth / width;

Expand Down
6 changes: 6 additions & 0 deletions web/pdf_thumbnail_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ class PDFThumbnailViewer {
this.#undoButton = undoBar?.viewsManagerStatusUndoButton || null;
this.#undoCloseButton = undoBar?.viewsManagerStatusUndoCloseButton || null;

PDFThumbnailView.setThumbnailBaseWidth(
parseFloat(
getComputedStyle(container).getPropertyValue("--thumbnail-width")
) || 126
);

// TODO: uncomment when the "add file" feature is implemented.
// this.#addFileButton = addFileButton;

Expand Down
Loading