diff --git a/src/components/MaintainersMap.tsx b/src/components/MaintainersMap.tsx index 933543bfa..5cea9f332 100644 --- a/src/components/MaintainersMap.tsx +++ b/src/components/MaintainersMap.tsx @@ -29,8 +29,8 @@ import { createChartsGlobe, globeHaloScale } from './maintainersChartsGlobe' import { initialMaintainersView, initialView } from './maintainersGlobeView' const zoomStep = 1.5 -const initialScale = initialView.scale * zoomStep -const mobileMaxZoom = initialScale * 1.2 +const desktopInitialScale = initialView.scale * zoomStep +const mobileMaxZoom = desktopInitialScale * 1.2 const mobileViewport = '(width < 40rem)' // Allow for rounding in rAF timestamps at 60 Hz and cap redraws on faster displays. const frameInterval = 1000 / 60 - 1 @@ -42,9 +42,15 @@ const globeRadius = 0.4 const globeAtmosphereDiameter = 2 * globeRadius * globeHaloScale const desktopProjectionDiameter = 0.9 const desktopMaxZoom = - (initialScale * desktopProjectionDiameter) / globeAtmosphereDiameter + (desktopInitialScale * desktopProjectionDiameter) / globeAtmosphereDiameter const zoomControls = { width: 46, height: 171 } +function getInitialScale() { + return window.matchMedia(mobileViewport).matches + ? mobileMaxZoom + : desktopInitialScale +} + type View = typeof initialView type Anchor = { x: number; y: number; visible: boolean } @@ -777,11 +783,10 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { const height = host.clientHeight const paintHeight = surface.clientHeight const limit = mobile.matches ? mobileMaxZoom : desktopMaxZoom - // Keep the desktop starting diameter. On mobile, fit to the smaller edge. + // At the mobile default, crop 3% of the viewport width from each side. const projectionHeight = mobile.matches - ? (Math.min(paintWidth, paintHeight) - 2 * viewportGutter) / - (globeAtmosphereDiameter * mobileMaxZoom) - : paintHeight / (initialScale * desktopProjectionDiameter) + ? (paintWidth * 1.06) / (2 * globeRadius * mobileMaxZoom) + : paintHeight / (desktopInitialScale * desktopProjectionDiameter) hostSize.current = { width, height, @@ -1102,6 +1107,7 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { wakeGlobe.current?.() }) selection.call(behavior) + const initialScale = getInitialScale() selection.call(behavior.transform, zoomIdentity.scale(initialScale)) view.current.scale = initialScale return () => { @@ -1170,7 +1176,7 @@ export function MaintainersMap({ maintainers }: MaintainersMapProps) { ) invalidate() }} - className="absolute inset-y-0 left-1/2 w-(--globe-width) -translate-x-1/2 outline-offset-4" + className="absolute inset-y-0 left-1/2 w-(--globe-width) -translate-x-1/2 outline-offset-4 max-sm:overflow-x-clip" >