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
@ -989,12 +989,7 @@ class PDFPageView {
|
|||||||
// drawing is complete when `!this.renderingQueue`, to prevent black
|
// drawing is complete when `!this.renderingQueue`, to prevent black
|
||||||
// flickering.
|
// flickering.
|
||||||
// In whatever case, the canvas must be the first child.
|
// In whatever case, the canvas must be the first child.
|
||||||
const { firstChild } = canvasWrapper;
|
canvasWrapper.prepend(canvas);
|
||||||
if (firstChild) {
|
|
||||||
firstChild.before(canvas);
|
|
||||||
} else {
|
|
||||||
canvasWrapper.append(canvas);
|
|
||||||
}
|
|
||||||
showCanvas = null;
|
showCanvas = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1006,12 +1001,7 @@ class PDFPageView {
|
|||||||
prevCanvas.replaceWith(canvas);
|
prevCanvas.replaceWith(canvas);
|
||||||
prevCanvas.width = prevCanvas.height = 0;
|
prevCanvas.width = prevCanvas.height = 0;
|
||||||
} else {
|
} else {
|
||||||
const { firstChild } = canvasWrapper;
|
canvasWrapper.prepend(canvas);
|
||||||
if (firstChild) {
|
|
||||||
firstChild.before(canvas);
|
|
||||||
} else {
|
|
||||||
canvasWrapper.append(canvas);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
showCanvas = null;
|
showCanvas = null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user