Introduce a viewer constant for document.documentElement.style

Over time, as we've been introducing JavaScript code to modify CSS variables, we've been adding shorthand properties to various classes to reduce unnecessary repetition when accessing the document-styles.
Rather than repeating this in multiple places, it seems overall simpler to just introduce a constant and re-use that throughout the viewer instead.
This commit is contained in:
Jonas Jenwald 2022-05-22 18:00:57 +02:00
parent 5b02c685d6
commit ca244d9bca
5 changed files with 21 additions and 13 deletions

View file

@ -17,6 +17,7 @@ import {
animationStarted,
DEFAULT_SCALE,
DEFAULT_SCALE_VALUE,
docStyle,
MAX_SCALE,
MIN_SCALE,
noContextMenuHandler,
@ -274,8 +275,7 @@ class Toolbar {
maxWidth += 2 * scaleSelectOverflow;
if (maxWidth > scaleSelectContainerWidth) {
const doc = document.documentElement;
doc.style.setProperty("--scale-select-container-width", `${maxWidth}px`);
docStyle.setProperty("--scale-select-container-width", `${maxWidth}px`);
}
// Zeroing the width and height cause Firefox to release graphics resources
// immediately, which can greatly reduce memory consumption.