diff --git a/package-lock.json b/package-lock.json index 0cf14de..9ccac09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "qortal-go", - "version": "0.3.3", + "version": "0.3.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "qortal-go", - "version": "0.3.3", + "version": "0.3.6", "dependencies": { "@capacitor/android": "^6.1.2", "@capacitor/app": "^6.0.1", @@ -68,6 +68,7 @@ "react-infinite-scroller": "^1.2.6", "react-intersection-observer": "^9.13.0", "react-qr-code": "^2.0.15", + "react-quick-pinch-zoom": "^5.1.0", "react-quill": "^2.0.0", "react-redux": "^9.1.2", "react-virtualized": "^9.22.5", @@ -11960,6 +11961,30 @@ "react": "*" } }, + "node_modules/react-quick-pinch-zoom": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/react-quick-pinch-zoom/-/react-quick-pinch-zoom-5.1.0.tgz", + "integrity": "sha512-c8iOBrhbWwuJkUgbM0itkxhYHN3Zc15fvwYclo52scuicPidOuXJxwoVboNtccgtG24w33EhpuKVA7aLt93oSA==", + "dependencies": { + "tslib": ">=2.0.0" + }, + "peerDependencies": { + "prop-types": ">=15.0.0", + "react": ">=16.4.0", + "react-dom": ">=16.4.0" + }, + "peerDependenciesMeta": { + "prop-types": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, "node_modules/react-quill": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/react-quill/-/react-quill-2.0.0.tgz", diff --git a/package.json b/package.json index a861b45..7d4d325 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "react-infinite-scroller": "^1.2.6", "react-intersection-observer": "^9.13.0", "react-qr-code": "^2.0.15", + "react-quick-pinch-zoom": "^5.1.0", "react-quill": "^2.0.0", "react-redux": "^9.1.2", "react-virtualized": "^9.22.5", diff --git a/src/components/Embeds/ImageEmbed.tsx b/src/components/Embeds/ImageEmbed.tsx index 0ac1a7c..29fd428 100644 --- a/src/components/Embeds/ImageEmbed.tsx +++ b/src/components/Embeds/ImageEmbed.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from "react"; +import React, { useCallback, useEffect, useRef, useState } from "react"; import { Card, CardContent, @@ -11,6 +11,8 @@ import { IconButton, } from "@mui/material"; +import QuickPinchZoom, { make3dTransformValue } from "react-quick-pinch-zoom"; + import RefreshIcon from "@mui/icons-material/Refresh"; import OpenInNewIcon from "@mui/icons-material/OpenInNew"; @@ -179,16 +181,25 @@ export const ImageCard = ({ export function ImageViewer({ src, alt = "" }) { const [isFullscreen, setIsFullscreen] = useState(false); + const imgRef = useRef(null); const handleOpenFullscreen = () => setIsFullscreen(true); const handleCloseFullscreen = () => setIsFullscreen(false); + const onUpdate = ({ x, y, scale }) => { + const img = imgRef.current; + if (img) { + const transformValue = make3dTransformValue({ x, y, scale }); + img.style.transform = transformValue; + } + }; + + return ( <> - {/* Image in container */} @@ -219,7 +230,7 @@ export const ImageCard = ({ maxWidth: "100%", width: "100%", height: "100vh", - overflow: "hidden", // Prevent scrollbars + overflow: "hidden", }, }} > @@ -228,10 +239,7 @@ export const ImageCard = ({ position: "relative", width: "100%", height: "100%", - display: "flex", - justifyContent: "center", - alignItems: "center", - backgroundColor: "#000", // Optional: dark background for fullscreen mode + backgroundColor: "#000", }} > {/* Close Button */} @@ -243,21 +251,28 @@ export const ImageCard = ({ right: 8, zIndex: 10, color: "white", + background: 'rgb(29, 29, 29)', + borderRadius: '50%', + padding: '5px' }} > - {/* Fullscreen Image */} - {alt} + {/* Fullscreen Image with Pinch-Zoom */} + + {alt} +