From 7f694e6ca72b7f71275ed2d5c9f10e604b25c421 Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Fri, 23 Aug 2024 18:58:51 -0500 Subject: [PATCH] fold handlePageChange directly into input onChange Moved the single-line handler to operate directly in the onChange handler of the input that is calling it. Considered doing the same with handleZoomChange, but that handler is used by two buttons rather than just one. --- .../homebrew/brewRenderer/toolBar/toolBar.jsx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/client/homebrew/brewRenderer/toolBar/toolBar.jsx b/client/homebrew/brewRenderer/toolBar/toolBar.jsx index a8ae7372e..fbfd4f8aa 100644 --- a/client/homebrew/brewRenderer/toolBar/toolBar.jsx +++ b/client/homebrew/brewRenderer/toolBar/toolBar.jsx @@ -19,14 +19,10 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{ setPageNum(currentPage); }, [currentPage]) - const handleZoomChange = (delta)=>{ - const zoomChange = _.clamp(zoomLevel + delta, MIN_ZOOM, MAX_ZOOM); + const handleZoomButton = (delta)=>{ + const newZoomLevel = _.clamp(zoomLevel + delta, MIN_ZOOM, MAX_ZOOM); - setZoomLevel(zoomChange); - }; - - const handlePageChange = (page)=>{ - setPageNum(page); + setZoomLevel(newZoomLevel); }; const scrollToPage = (pageNumber) => { @@ -47,7 +43,7 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{