1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Merge pull request #12870 from Snuffleupagus/page-advance

Add previous/next-page functionality that takes scroll/spread-modes into account (issue 11946)
This commit is contained in:
Tim van der Meij 2021-01-23 19:35:08 +01:00 committed by GitHub
commit d4c4f5d4e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 178 additions and 56 deletions

View file

@ -650,11 +650,21 @@ describe("ui_utils", function () {
const hiddenWidth =
Math.max(0, scrollLeft - viewLeft) +
Math.max(0, viewRight - scrollRight);
const visibleArea =
(div.clientHeight - hiddenHeight) * (div.clientWidth - hiddenWidth);
const percent =
((visibleArea * 100) / div.clientHeight / div.clientWidth) | 0;
views.push({ id: view.id, x: viewLeft, y: viewTop, view, percent });
const fractionHeight =
(div.clientHeight - hiddenHeight) / div.clientHeight;
const fractionWidth =
(div.clientWidth - hiddenWidth) / div.clientWidth;
const percent = (fractionHeight * fractionWidth * 100) | 0;
views.push({
id: view.id,
x: viewLeft,
y: viewTop,
view,
percent,
widthPercent: (fractionWidth * 100) | 0,
});
}
}
return { first: views[0], last: views[views.length - 1], views };