MCPcopy Create free account
hub / github.com/abi/screenshot-to-code / zoomToDefault

Function zoomToDefault

frontend/src/components/ImageLightbox.tsx:89–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87 const zoomToFit = () => setZoom(1);
88
89 const zoomToDefault = () => {
90 if (!naturalSize || fitScale <= 0 || !viewportRef.current) return;
91 const viewportWidth = viewportRef.current.clientWidth - 64;
92 const targetScale = DEFAULT_DISPLAY_WIDTH / naturalSize.width;
93 const maxWidthScale = viewportWidth / naturalSize.width;
94 const clampedScale = Math.min(targetScale, maxWidthScale);
95 setZoom(Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, clampedScale / fitScale)));
96 };
97
98 const handleMouseDown = useCallback((e: React.MouseEvent) => {
99 if (!viewportRef.current || e.button !== 0) return;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected