diff --git a/web/toolbar.js b/web/toolbar.js index 5aa1313b1..af8bc2158 100644 --- a/web/toolbar.js +++ b/web/toolbar.js @@ -17,7 +17,6 @@ import { animationStarted, DEFAULT_SCALE, DEFAULT_SCALE_VALUE, - docStyle, MAX_SCALE, MIN_SCALE, noContextMenuHandler, @@ -342,7 +341,8 @@ class Toolbar { maxWidth += 0.3 * scaleSelectWidth; if (maxWidth > scaleSelectWidth) { - docStyle.setProperty("--scale-select-width", `${maxWidth}px`); + const container = items.scaleSelect.parentNode; + container.style.setProperty("--scale-select-width", `${maxWidth}px`); } // Zeroing the width and height cause Firefox to release graphics resources // immediately, which can greatly reduce memory consumption. diff --git a/web/viewer.css b/web/viewer.css index 3a79aa4f2..68842a724 100644 --- a/web/viewer.css +++ b/web/viewer.css @@ -20,7 +20,6 @@ --sidebar-width: 200px; --sidebar-transition-duration: 200ms; --sidebar-transition-timing-function: ease; - --scale-select-width: 140px; --toolbar-icon-opacity: 0.7; --doorhanger-icon-opacity: 0.9; @@ -799,6 +798,10 @@ body { } .dropdownToolbarButton { + /* Define this variable here, and not in :root, to avoid reflowing the + entire viewer when updating the width. */ + --scale-select-width: 140px; + width: var(--scale-select-width); padding: 0; background-color: var(--dropdown-btn-bg-color);