diff --git a/client/homebrew/brewRenderer/toolBar/toolBar.jsx b/client/homebrew/brewRenderer/toolBar/toolBar.jsx index 7a111fbb8..227b40a64 100644 --- a/client/homebrew/brewRenderer/toolBar/toolBar.jsx +++ b/client/homebrew/brewRenderer/toolBar/toolBar.jsx @@ -20,8 +20,8 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{ setPageNum(currentPage); }, [currentPage]); - const handleZoomButton = (delta)=>{ - setZoomLevel(_.round(_.clamp(zoomLevel + delta, MIN_ZOOM, MAX_ZOOM))); + const handleZoomButton = (zoom)=>{ + setZoomLevel(_.round(_.clamp(zoom, MIN_ZOOM, MAX_ZOOM))); }; const handlePageInput = (pageInput)=>{ @@ -39,7 +39,7 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{ }; - const calculateZoom = (mode)=>{ + const calculateChange = (mode)=>{ const iframe = document.getElementById('BrewRenderer'); const iframeWidth = iframe.getBoundingClientRect().width; const iframeHeight = iframe.getBoundingClientRect().height; @@ -49,12 +49,7 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{ if(mode == 'fill'){ // find widest page, in case pages are different widths, so that the zoom is adapted to not cut the widest page off screen. - let widestPage = 0; - [...pages].forEach((page)=>{ - const width = page.offsetWidth; - if(width > widestPage) - widestPage = width; - }); + const widestPage = _.maxBy([...pages], 'offsetWidth').offsetWidth; desiredZoom = (iframeWidth / widestPage) * 100; @@ -88,21 +83,21 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{