mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-07 15:45:48 +02:00
Fix the drag marker dimensions in the thumbnails view
STR: - open outline view; - switch to thumbnails one; - start to drag a thumbnail.
This commit is contained in:
parent
001058abb2
commit
f2ac669ee4
@ -486,4 +486,71 @@ describe("Reorganize Pages View", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Drag marker must have the right non-zero dimensions", () => {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
pages = await loadAndWait(
|
||||||
|
"page_with_number_and_link.pdf",
|
||||||
|
"#viewsManagerToggleButton",
|
||||||
|
"1",
|
||||||
|
null,
|
||||||
|
{
|
||||||
|
enableSplitMerge: true,
|
||||||
|
sidebarViewOnLoad: 2 /* = SidebarView.OUTLINES */,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should check if the drag marker width is non-zero", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await page.waitForSelector("#outlinesView", { visible: true });
|
||||||
|
await page.waitForSelector("#viewsManagerSelectorButton", {
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
await page.click("#viewsManagerSelectorButton");
|
||||||
|
await page.waitForSelector("#thumbnailsViewMenu", { visible: true });
|
||||||
|
await page.click("#thumbnailsViewMenu");
|
||||||
|
|
||||||
|
const thumbSelector = "#thumbnailsView .thumbnailImage";
|
||||||
|
await page.waitForSelector(thumbSelector, { visible: true });
|
||||||
|
const rect1 = await getRect(page, getThumbnailSelector(1));
|
||||||
|
const rect2 = await getRect(page, getThumbnailSelector(2));
|
||||||
|
|
||||||
|
const handleAddedMarker = await waitForDOMMutation(
|
||||||
|
page,
|
||||||
|
mutationList => {
|
||||||
|
for (const mutation of mutationList) {
|
||||||
|
if (mutation.type !== "childList") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const node of mutation.addedNodes) {
|
||||||
|
if (node.classList.contains("dragMarker")) {
|
||||||
|
const rect = node.getBoundingClientRect();
|
||||||
|
return rect.width !== 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await dragAndDrop(
|
||||||
|
page,
|
||||||
|
getThumbnailSelector(1),
|
||||||
|
[[0, rect2.y - rect1.y + rect2.height / 2]],
|
||||||
|
10
|
||||||
|
);
|
||||||
|
|
||||||
|
await awaitPromise(handleAddedMarker);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -388,6 +388,7 @@ const PDFViewerApplication = {
|
|||||||
pageColorsBackground: x => x,
|
pageColorsBackground: x => x,
|
||||||
pageColorsForeground: x => x,
|
pageColorsForeground: x => x,
|
||||||
localeProperties: x => ({ lang: x }),
|
localeProperties: x => ({ lang: x }),
|
||||||
|
sidebarViewOnLoad: x => parseInt(x),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -635,6 +635,10 @@ class PDFThumbnailViewer {
|
|||||||
offsetWidth: w,
|
offsetWidth: w,
|
||||||
offsetHeight: h,
|
offsetHeight: h,
|
||||||
} = div;
|
} = div;
|
||||||
|
if (w === 0) {
|
||||||
|
// The thumbnail view isn't visible.
|
||||||
|
return;
|
||||||
|
}
|
||||||
bbox[i * 4] = x;
|
bbox[i * 4] = x;
|
||||||
bbox[i * 4 + 1] = y;
|
bbox[i * 4 + 1] = y;
|
||||||
bbox[i * 4 + 2] = w;
|
bbox[i * 4 + 2] = w;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user