mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Simplify logic to insert canvas as first element
Instead of conditionally checking if the `.cavnasWrapper` already has a child element and then inserting the `canvas` before it, we can use `.prepend` which always injects the new element as the first child.
This commit is contained in:
parent
44421d36f6
commit
62db66dd46
1 changed files with 2 additions and 12 deletions
|
@ -989,12 +989,7 @@ class PDFPageView {
|
|||
// drawing is complete when `!this.renderingQueue`, to prevent black
|
||||
// flickering.
|
||||
// In whatever case, the canvas must be the first child.
|
||||
const { firstChild } = canvasWrapper;
|
||||
if (firstChild) {
|
||||
firstChild.before(canvas);
|
||||
} else {
|
||||
canvasWrapper.append(canvas);
|
||||
}
|
||||
canvasWrapper.prepend(canvas);
|
||||
showCanvas = null;
|
||||
return;
|
||||
}
|
||||
|
@ -1006,12 +1001,7 @@ class PDFPageView {
|
|||
prevCanvas.replaceWith(canvas);
|
||||
prevCanvas.width = prevCanvas.height = 0;
|
||||
} else {
|
||||
const { firstChild } = canvasWrapper;
|
||||
if (firstChild) {
|
||||
firstChild.before(canvas);
|
||||
} else {
|
||||
canvasWrapper.append(canvas);
|
||||
}
|
||||
canvasWrapper.prepend(canvas);
|
||||
}
|
||||
|
||||
showCanvas = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue