From 6a44dced0b7ab12e43cf03c07ff8171ed0449c74 Mon Sep 17 00:00:00 2001 From: bw2 Date: Mon, 20 Nov 2023 13:34:31 -0500 Subject: [PATCH] Zoom in/out on-click to enable faster review of STR readviz images (#1303) --- .../ShortTandemRepeatReads.tsx | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/browser/src/ShortTandemRepeatPage/ShortTandemRepeatReads.tsx b/browser/src/ShortTandemRepeatPage/ShortTandemRepeatReads.tsx index 8bb9ab1d8..c7951b5b0 100644 --- a/browser/src/ShortTandemRepeatPage/ShortTandemRepeatReads.tsx +++ b/browser/src/ShortTandemRepeatPage/ShortTandemRepeatReads.tsx @@ -14,12 +14,23 @@ import ControlSection from '../VariantPage/ControlSection' import { ShortTandemRepeatPropType } from './ShortTandemRepeatPropTypes' const ShortTandemRepeatReadImageWrapper = styled.div` - overflow-x: auto; width: 100%; ` const ShortTandemRepeatReadImage = styled.img` - display: block; + &.zoomedOut { + display: block; + max-width: 100%; + cursor: zoom-in; + } + + &.zoomedIn { + position: absolute; + left: 0; + display: block; + cursor: zoom-out; + padding: 10px; + } ` type ShortTandemRepeatReadProps = { @@ -41,6 +52,8 @@ type ShortTandemRepeatReadProps = { } const ShortTandemRepeatRead = ({ read }: ShortTandemRepeatReadProps) => { + const [readImageZoom, setReadImageZoom] = useState('zoomedOut') + return (
@@ -79,9 +92,12 @@ const ShortTandemRepeatRead = ({ read }: ShortTandemRepeatReadProps) => { - - - + setReadImageZoom(readImageZoom === 'zoomedOut' ? 'zoomedIn' : 'zoomedOut')} + />
) @@ -209,7 +225,7 @@ const ShortTandemRepeatReads = ({ fetchReadsTimer.current = setTimeout(() => { fetchNumReads({ datasetId, shortTandemRepeatId: shortTandemRepeat.id, filter }).then( resolve, - reject + reject, ) }, 300) }) @@ -251,7 +267,7 @@ const ShortTandemRepeatReads = ({ const read = i < fetchedReads.length ? fetchedReads[i] : null readsStore.current.set(readIndexToFetch + i, read) return read - }) + }), ) }) @@ -372,8 +388,8 @@ const ShortTandemRepeatReadsAllelesFilterControls = ({ const newRepeatUnit = e.target.value onChange( value.map((v, i) => - i === alleleIndex ? { ...v, repeat_unit: newRepeatUnit } : v - ) + i === alleleIndex ? { ...v, repeat_unit: newRepeatUnit } : v, + ), ) }} > @@ -399,8 +415,8 @@ const ShortTandemRepeatReadsAllelesFilterControls = ({ const newMinRepeats = Math.max(Math.min(Number(e.target.value), maxNumRepeats), 0) onChange( value.map((v, i) => - i === alleleIndex ? { ...v, min_repeats: newMinRepeats } : v - ) + i === alleleIndex ? { ...v, min_repeats: newMinRepeats } : v, + ), ) }} /> @@ -417,8 +433,8 @@ const ShortTandemRepeatReadsAllelesFilterControls = ({ const newMaxRepeats = Math.max(Math.min(Number(e.target.value), maxNumRepeats), 0) onChange( value.map((v, i) => - i === alleleIndex ? { ...v, max_repeats: newMaxRepeats } : v - ) + i === alleleIndex ? { ...v, max_repeats: newMaxRepeats } : v, + ), ) }} />