From e92bf5fa2058452a9498776f444501791c3e96c2 Mon Sep 17 00:00:00 2001 From: Rebecca Black Date: Thu, 14 Mar 2024 15:10:48 -0400 Subject: [PATCH] Fixing zoom control and help popup bugs (#78) * trying width and height auto * resize based on container * add loading spinner component * added loading spinner to image and transcription views * made dropdown and help icon visible on single pane * improved layout of nav at small widths * improvement to color of nav row for imageview * fixed imageview zoom buttons * fixed positioning issue of help popup * fix merge errors in navigation --- editioncrafter/src/component/ImageView.js | 16 +++++++++--- editioncrafter/src/component/Navigation.js | 26 +++++++++++++------ editioncrafter/src/component/RingSpinner.js | 3 ++- .../src/component/SeaDragonComponent.js | 13 +++++++--- 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/editioncrafter/src/component/ImageView.js b/editioncrafter/src/component/ImageView.js index c83f047..8613e2d 100644 --- a/editioncrafter/src/component/ImageView.js +++ b/editioncrafter/src/component/ImageView.js @@ -18,6 +18,14 @@ const ImageView = (props) => { const [viewer, setViewer] = useState(null); const [anno, setAnno] = useState(null); + // const [onZoomFixed_1, setOnZoomFixed_1] = useState(() => null); + // const [onZoomFixed_2, setOnZoomFixed_2] = useState(() => null); + // const [onZoomFixed_3, setOnZoomFixed_3] = useState(() => null); + // const [onZoomOut, setOnZoomOut] = useState(() => null); + // const [onZoomIn, setOnZoomIn] = useState(() => null); + + + const location = useLocation(); const navigate = useNavigate(); @@ -40,7 +48,7 @@ const ImageView = (props) => { viewer.viewport.zoomTo(viewer.viewport.getMaxZoom()); }; - const onZoomFixed_2 = (e) => { + const onZoomFixed_2= (e) => { viewer.viewport.zoomTo((viewer.viewport.getMaxZoom() / 2)); }; @@ -49,12 +57,13 @@ const ImageView = (props) => { }; const onZoomIn = (e) => { + console.log(viewer.viewport.fitVertically()); viewer.viewport.zoomBy(2) - } + }; const onZoomOut = (e) => { viewer.viewport.zoomBy(0.5) - } + }; useEffect(() => { if (anno) { @@ -155,6 +164,7 @@ const ImageView = (props) => { onZoomGrid={onZoomGrid} onZoomIn={onZoomIn} onZoomOut={onZoomOut} + viewer={viewer} /> { const [popover, setPopover] = useState({ ...initialPopoverObj }); const [openHelp, setOpenHelp] = useState(false); + const [openHelpNarrow, setOpenHelpNarrow] = useState(false); const helpRef = useRef(null); + const helpRefNarrow = useRef(null); + + useEffect(() => { + console.log(helpRef.current); + }, []); const onJumpBoxBlur = (event) => { setPopover({ ...popover, show: false }); @@ -44,6 +50,10 @@ const Navigation = (props) => { setOpenHelp(!openHelp); }; + const toggleHelpNarrow = (event) => { + setOpenHelpNarrow(!openHelpNarrow); + }; + const toggleBookmode = (event) => { if (!props.documentView.bookMode) { props.documentViewActions.changeCurrentFolio( @@ -216,7 +226,7 @@ const Navigation = (props) => { {' '} {' '} - + { ) : ()} -
{ helpRef.current = e; }}> +
{
diff --git a/editioncrafter/src/component/RingSpinner.js b/editioncrafter/src/component/RingSpinner.js index e884562..fb5cb67 100644 --- a/editioncrafter/src/component/RingSpinner.js +++ b/editioncrafter/src/component/RingSpinner.js @@ -12,9 +12,10 @@ export function BigRingSpinner(props) { useEffect(() => { if (delay > 0) { - setTimeout(() => { + const timer = setTimeout(() => { setShow(true) }, delay); + return () => clearTimeout(timer); } }, []); diff --git a/editioncrafter/src/component/SeaDragonComponent.js b/editioncrafter/src/component/SeaDragonComponent.js index 0614930..c6e6528 100644 --- a/editioncrafter/src/component/SeaDragonComponent.js +++ b/editioncrafter/src/component/SeaDragonComponent.js @@ -1,13 +1,20 @@ -import React, { useMemo, useState } from 'react'; +import React, { useEffect, useMemo, useRef, useState } from 'react'; import { BigRingSpinner } from './RingSpinner'; const SeaDragonComponent = (props) => { const { side, initViewer, tileSource } = props; const [loading, setLoading] = useState(true); + const viewerRef = useRef(null); + + useEffect(async () => { + if (viewerRef.current) { + await initViewer(viewerRef.current, tileSource).then(() => setLoading(false)); + } + }, []); const viewer = useMemo(() => ( -
{ initViewer(el, tileSource).then(() => {setLoading(false);}) }}> - { loading && } +
+ { loading && }
), [loading]);