Skip to content

Commit

Permalink
Fix Graph zoomed in value
Browse files Browse the repository at this point in the history
  • Loading branch information
lubej committed Jul 20, 2023
1 parent 49e750e commit 707fce2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .changelog/759.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix Graph zoomed in value
15 changes: 9 additions & 6 deletions src/app/pages/HomePage/Graph/ParaTimeSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const ZoomOutBtnFade = styled(Fade)(() => ({
transitionDelay: '500ms !important',
}))

// border affecting scale (quick-pinch-zoom)
const QuickPinchZoomOuter = styled('div')(({ theme }) => ({
'> div': {
position: 'absolute',
Expand All @@ -152,6 +153,7 @@ interface ParaTimeSelectorProps extends ParaTimeSelectorBaseProps {
step: ParaTimeSelectorStep
setStep: (value: ParaTimeSelectorStep) => void
showInfoScreen: boolean
graphZoomedIn: boolean
onGraphZoomedIn: (isGraphZoomedIn: boolean) => void
}

Expand All @@ -162,6 +164,7 @@ const ParaTimeSelectorCmp: FC<ParaTimeSelectorProps> = ({
step,
setStep,
showInfoScreen,
graphZoomedIn,
onGraphZoomedIn,
}) => {
const graphRef = useRef<SVGSVGElement & HTMLElement>(null)
Expand Down Expand Up @@ -227,12 +230,12 @@ const ParaTimeSelectorCmp: FC<ParaTimeSelectorProps> = ({
}
}

// true when scale larger than initial zoom
const isZoomedIn = scale > 1.07

useEffect(() => {
// true when scale larger than "safe" zoom, due to viewport
const isZoomedIn = scale > 1.5

onGraphZoomedIn(isZoomedIn)
}, [isZoomedIn, onGraphZoomedIn])
}, [scale, onGraphZoomedIn])

return (
<>
Expand All @@ -256,13 +259,13 @@ const ParaTimeSelectorCmp: FC<ParaTimeSelectorProps> = ({
setSelectedLayer={(layer: Layer) => setSelectedLayer({ current: layer })}
scale={scale}
setActiveMobileGraphTooltip={setActiveMobileGraphTooltip}
isZoomedIn={isZoomedIn}
isZoomedIn={graphZoomedIn}
/>
</QuickPinchZoomInner>
</QuickPinchZoom>
</QuickPinchZoomOuter>
{!isMobile && (
<ZoomOutBtnFade in={isZoomedIn}>
<ZoomOutBtnFade in={graphZoomedIn}>
<ZoomOutBtn onClick={onZoomOutClick} disabled={disabled}>
{t('home.zoomOutBtnText')}
</ZoomOutBtn>
Expand Down
1 change: 1 addition & 0 deletions src/app/pages/HomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const HomePage: FC = () => {
setStep={setStep}
disabled={searchHasFocus}
showInfoScreen={showInfoScreen}
graphZoomedIn={isGraphZoomedIn}
onGraphZoomedIn={setIsGraphZoomedIn}
/>
</Box>
Expand Down

0 comments on commit 707fce2

Please sign in to comment.