Move the --scale-select-width
CSS variable to the relevant DOM element
The default value of the `--scale-select-width` CSS variable has been choosen such that it should be large enough for most locales. This means that in many locales we don't even update the CSS variable at all, and for those locales where we do the update happens *one time* early during the viewer initialization (i.e. before the PDF document has loaded). *Please note:* Compared to other recent PRs, the effect of these changes ought to be really tiny and are mostly done to promote better coding patterns.
This commit is contained in:
parent
25253034d5
commit
849b492b33
@ -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.
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user