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

Merge pull request #14219 from Snuffleupagus/getVisibleElements-ids

Let `getVisibleElements` return a Set containing the visible element `id`s
This commit is contained in:
Jonas Jenwald 2021-11-03 23:49:27 +01:00 committed by GitHub
commit 611627f5a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 40 deletions

View file

@ -497,7 +497,8 @@ describe("ui_utils", function () {
// This is a reimplementation of getVisibleElements without the
// optimizations.
function slowGetVisibleElements(scroll, pages) {
const views = [];
const views = [],
ids = new Set();
const { scrollLeft, scrollTop } = scroll;
const scrollRight = scrollLeft + scroll.clientWidth;
const scrollBottom = scrollTop + scroll.clientHeight;
@ -535,9 +536,10 @@ describe("ui_utils", function () {
percent,
widthPercent: (fractionWidth * 100) | 0,
});
ids.add(view.id);
}
}
return { first: views[0], last: views[views.length - 1], views };
return { first: views[0], last: views[views.length - 1], views, ids };
}
// This function takes a fixed layout of pages and compares the system under
@ -699,6 +701,7 @@ describe("ui_utils", function () {
first: undefined,
last: undefined,
views: [],
ids: new Set(),
});
});
@ -715,6 +718,7 @@ describe("ui_utils", function () {
first: undefined,
last: undefined,
views: [],
ids: new Set(),
});
});