viewer: replace window with globalThis

This commit is contained in:
octocorvus 2023-08-03 07:58:34 +00:00 committed by Daniel Micay
parent 627a566c2f
commit c0148fc483

View File

@ -144,7 +144,7 @@ function renderPage(pageNumber, zoom, prerender, prerenderTrigger=0) {
} }
const newCanvas = document.createElement("canvas"); const newCanvas = document.createElement("canvas");
const ratio = window.devicePixelRatio; const ratio = globalThis.devicePixelRatio;
newCanvas.height = viewport.height * ratio; newCanvas.height = viewport.height * ratio;
newCanvas.width = viewport.width * ratio; newCanvas.width = viewport.width * ratio;
newCanvas.style.height = viewport.height + "px"; newCanvas.style.height = viewport.height + "px";
@ -240,7 +240,7 @@ globalThis.onRenderPage = function (zoom) {
}; };
globalThis.isTextSelected = function () { globalThis.isTextSelected = function () {
return window.getSelection().toString() !== ""; return globalThis.getSelection().toString() !== "";
}; };
globalThis.toggleTextLayerVisibility = function () { globalThis.toggleTextLayerVisibility = function () {
@ -281,6 +281,6 @@ globalThis.loadDocument = function () {
}); });
}; };
window.onresize = () => { globalThis.onresize = () => {
setLayerTransform(canvas.clientWidth, canvas.clientHeight, textLayerDiv); setLayerTransform(canvas.clientWidth, canvas.clientHeight, textLayerDiv);
}; };