0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-18 07:52:41 +00:00

change the toFit method to toFill

Realized this method is filling the preview pane, and that toFit would force the zoom to show the entirety of a single page at once.
This commit is contained in:
Gazook89
2024-08-22 15:54:58 -05:00
parent 8965bb60aa
commit 4c71987866

View File

@@ -42,7 +42,7 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
}; };
const toFit = ()=>{ const toFill = ()=>{
const iframe = document.getElementById('BrewRenderer'); const iframe = document.getElementById('BrewRenderer');
const iframeWidth = iframe.getBoundingClientRect().width; const iframeWidth = iframe.getBoundingClientRect().width;
const pages = iframe.contentWindow.document.getElementsByClassName('page'); const pages = iframe.contentWindow.document.getElementsByClassName('page');
@@ -55,7 +55,7 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
widestPage = width; widestPage = width;
}); });
const margin = 5; // extra space so page isn't edge to edge (not truly "to fit") const margin = 5; // extra space so page isn't edge to edge (not truly "to fill")
const desiredZoom = (iframeWidth / widestPage) * 100; const desiredZoom = (iframeWidth / widestPage) * 100;
const deltaZoom = (desiredZoom - zoomLevel) - margin; const deltaZoom = (desiredZoom - zoomLevel) - margin;
return deltaZoom; return deltaZoom;
@@ -65,11 +65,11 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
<div className='toolBar'> <div className='toolBar'>
<div className='group'> <div className='group'>
<button <button
id='zoom-to-fit' id='zoom-to-fill'
className='tool' className='tool'
onClick={()=>handleZoomChange(toFit())} onClick={()=>handleZoomChange(toFill())}
> >
toFit toFill
</button> </button>
<button <button
id='zoom-out' id='zoom-out'