Merge pull request #10255 from Snuffleupagus/renderMatches-less-scrollMatchIntoView

Avoid unnecessary `PDFFindController.scrollMatchIntoView` calls in `TextLayerBuilder._renderMatches` when `highlightAll` is set (PR 10201 follow-up)
This commit is contained in:
Tim van der Meij 2018-11-16 23:04:00 +01:00 committed by GitHub
commit e3e7ccc3e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -238,15 +238,16 @@ class TextLayerBuilder {
let match = matches[i];
let begin = match.begin;
let end = match.end;
let isSelected = (isSelectedPage && i === selectedMatchIdx);
let highlightSuffix = (isSelected ? ' selected' : '');
const isSelected = (isSelectedPage && i === selectedMatchIdx);
const highlightSuffix = (isSelected ? ' selected' : '');
// Attempt to scroll the selected match into view.
findController.scrollMatchIntoView({
element: textDivs[begin.divIdx],
pageIndex: pageIdx,
matchIndex: i,
});
if (isSelected) { // Attempt to scroll the selected match into view.
findController.scrollMatchIntoView({
element: textDivs[begin.divIdx],
pageIndex: pageIdx,
matchIndex: selectedMatchIdx,
});
}
// Match inside new div.
if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {