mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 18:25:37 +02:00
[api-minor] Sort PopupAnnotations already on the worker-thread (PR 11535 follow-up)
By doing this in the worker-thread this code will only need to run *once*, whereas currently re-rendering of a page forces this to be repeated (e.g. after it's been scrolled out-of-view and then back into view again).
This commit is contained in:
parent
d6d4653d80
commit
876a02a504
3 changed files with 33 additions and 24 deletions
|
@ -2477,30 +2477,13 @@ class AnnotationLayer {
|
|||
|
||||
this.#setDimensions(div, viewport);
|
||||
|
||||
const sortedAnnotations = [],
|
||||
popupAnnotations = [];
|
||||
// Ensure that Popup annotations are handled last, since they're dependant
|
||||
// upon the parent annotation having already been rendered (please refer to
|
||||
// the `PopupAnnotationElement.render` method); fixes issue 11362.
|
||||
for (const data of annotations) {
|
||||
if (!data) {
|
||||
continue;
|
||||
if (data.annotationType !== AnnotationType.POPUP) {
|
||||
const { width, height } = getRectDims(data.rect);
|
||||
if (width <= 0 || height <= 0) {
|
||||
continue; // Ignore empty annotations.
|
||||
}
|
||||
}
|
||||
if (data.annotationType === AnnotationType.POPUP) {
|
||||
popupAnnotations.push(data);
|
||||
continue;
|
||||
}
|
||||
const { width, height } = getRectDims(data.rect);
|
||||
if (width <= 0 || height <= 0) {
|
||||
continue; // Ignore empty annotations.
|
||||
}
|
||||
sortedAnnotations.push(data);
|
||||
}
|
||||
if (popupAnnotations.length) {
|
||||
sortedAnnotations.push(...popupAnnotations);
|
||||
}
|
||||
|
||||
for (const data of sortedAnnotations) {
|
||||
const element = AnnotationElementFactory.create({
|
||||
data,
|
||||
layer: div,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue