diff --git a/renderer/components/main-content/lens-view.tsx b/renderer/components/main-content/lens-view.tsx index ac27949..b11f6ff 100644 --- a/renderer/components/main-content/lens-view.tsx +++ b/renderer/components/main-content/lens-view.tsx @@ -37,66 +37,86 @@ const LensViewer = ({ sanitizedImagePath: string; sanitizedUpscaledImagePath: string; }) => { - const upscaledImageRef = useRef(null); + const [hoverPosition, setHoverPosition] = useState({ x: 0, y: 0 }); + const [isHovering, setIsHovering] = useState(false); - const [lensPosition, setLensPosition] = useState({ x: 0, y: 0 }); + const handleMouseMove = (e) => { + const { left, top, width, height } = + e.currentTarget.getBoundingClientRect(); + const x = ((e.clientX - left) / width) * 100; + const y = ((e.clientY - top) / height) * 100; - 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)), - }); - } + setHoverPosition({ x, y }); }; + const handleMouseEnter = () => setIsHovering(true); + const handleMouseLeave = () => setIsHovering(false); + + const originalImage = "file:///" + sanitizedImagePath; + const upscaledImage = "file:///" + sanitizedUpscaledImagePath; + return ( -
- {/* UPSCALED IMAGE */} - Upscaled - {/* LENS */} +
+ {/* Main image container */}
-
- + {isHovering && ( +
- -
-
- Original - Upscayl -
+ )}
+ + {/* Enlarged views for original and upscaled images */} + {isHovering && ( +
+
+ + Original + +
+
+ + AI Upscaled + +
+
+ )}
); };