import React, { useRef, useState } from "react"; const LensImage = ({ src, alt, lensPosition, zoomAmount, }: { src: string; alt: string; lensPosition: { x: number; y: number }; zoomAmount: number; }) => (
{alt}
); const LensViewer = ({ zoomAmount, lensSize, sanitizedImagePath, sanitizedUpscaledImagePath, }: { zoomAmount: string; lensSize: number; sanitizedImagePath: string; sanitizedUpscaledImagePath: string; }) => { const upscaledImageRef = useRef(null); const [lensPosition, setLensPosition] = useState({ x: 0, y: 0 }); const handleMouseMoveCompare = (e: React.MouseEvent) => { if (upscaledImageRef.current) { const { left, top, width, height } = upscaledImageRef.current.getBoundingClientRect(); const x = e.clientX - left; const y = e.clientY - top; setLensPosition({ x: Math.max(0, Math.min(x - lensSize, width - lensSize * 2)), y: Math.max(0, Math.min(y - lensSize / 2, height - lensSize)), }); } }; return (
{/* UPSCALED IMAGE */} Upscaled {/* LENS */}
Original Upscayl
); }; export default LensViewer;