Change the getVisibleElements helper function to take a parameter object

Given the number of parameters, and the fact that many of them are booleans, the call-sites are no longer particularly easy to read and understand. Furthermore, this slightly improves the formatting of the JSDoc-comment, since it needed updating as part of these changes anyway.

Finally, this removes an unnecessary `numViews === 0` check from `getVisibleElements`, since that should be *very* rare and more importantly that the `binarySearchFirstItem` function already has a fast-path for that particular case.
This commit is contained in:
Jonas Jenwald 2020-11-04 12:05:29 +01:00
parent 4e13559cb0
commit ba761e42f0
4 changed files with 55 additions and 41 deletions

View file

@ -81,7 +81,10 @@ class PDFThumbnailViewer {
* @private
*/
_getVisibleThumbs() {
return getVisibleElements(this.container, this._thumbnails);
return getVisibleElements({
scrollEl: this.container,
views: this._thumbnails,
});
}
scrollThumbnailIntoView(pageNumber) {