From 63add047b6cccc78d9cd371c6483f7c7292efafb Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Wed, 6 Nov 2024 23:03:24 -0600 Subject: [PATCH] 'fit page' zoom button fits two pages in "facing" spread If the 'facing' spread is active, the 'fit to view' zoom button fits two pages side by side in the view, rather than setting only one page in view. --- client/homebrew/brewRenderer/toolBar/toolBar.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/homebrew/brewRenderer/toolBar/toolBar.jsx b/client/homebrew/brewRenderer/toolBar/toolBar.jsx index 50fce0eed..d9c57e2c4 100644 --- a/client/homebrew/brewRenderer/toolBar/toolBar.jsx +++ b/client/homebrew/brewRenderer/toolBar/toolBar.jsx @@ -60,8 +60,14 @@ const ToolBar = ({ displayOptions, onDisplayOptionsChange, visiblePages, totalPa desiredZoom = (iframeWidth / widestPage) * 100; } else if(mode == 'fit'){ + let minDimRatio; // find the page with the largest single dim (height or width) so that zoom can be adapted to fit it. - const minDimRatio = [...pages].reduce((minRatio, page)=>Math.min(minRatio, iframeWidth / page.offsetWidth, iframeHeight / page.offsetHeight), Infinity); + if(displayOptions.spread === 'facing'){ + minDimRatio = [...pages].reduce((minRatio, page)=>Math.min(minRatio, iframeWidth / page.offsetWidth / 2), Infinity); // if 'facing' spread, fit two pages in view + } else { + minDimRatio = [...pages].reduce((minRatio, page)=>Math.min(minRatio, iframeWidth / page.offsetWidth, iframeHeight / page.offsetHeight), Infinity); + } + console.log(minDimRatio) desiredZoom = minDimRatio * 100; }