diff --git a/web/pdf_sidebar_resizer.js b/web/pdf_sidebar_resizer.js index 668c59dcb..b3f5b178c 100644 --- a/web/pdf_sidebar_resizer.js +++ b/web/pdf_sidebar_resizer.js @@ -13,7 +13,7 @@ * limitations under the License. */ -import { clamp, NullL10n } from "./ui_utils.js"; +import { NullL10n } from "./ui_utils.js"; const SIDEBAR_WIDTH_VAR = "--sidebar-width"; const SIDEBAR_MIN_WIDTH = 200; // pixels @@ -88,17 +88,19 @@ class PDFSidebarResizer { } // Prevent the sidebar from becoming too narrow, or from occupying more // than half of the available viewer width. - const newWidth = clamp( - width, - SIDEBAR_MIN_WIDTH, - Math.floor(this.outerContainerWidth / 2) - ); + const maxWidth = Math.floor(this.outerContainerWidth / 2); + if (width > maxWidth) { + width = maxWidth; + } + if (width < SIDEBAR_MIN_WIDTH) { + width = SIDEBAR_MIN_WIDTH; + } // Only update the UI when the sidebar width did in fact change. - if (newWidth === this._width) { + if (width === this._width) { return false; } - this._width = newWidth; - this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, `${newWidth}px`); + this._width = width; + this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`); return true; } diff --git a/web/ui_utils.js b/web/ui_utils.js index d08497165..4d007703d 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -1006,7 +1006,6 @@ export { SpreadMode, NullL10n, EventBus, - clamp, ProgressBar, getPDFFileNameFromURL, noContextMenuHandler,