-
Using the image-zoom component, I'm currently setting the tailwind class <ImageZoom
src={exampleImage}
className="border-2 rounded-full h-auto w-[220px] my-0"
zoomInProps={{
className: "rounded-full"
}}
alt="Example Image"
/> This works for the start and end state of the image during the zoom action, but not in the transition (i.e. going from not zoomed to zoom). Is there any other props that we can use to make the image remain rounded for the full duration? I've consulted the documentation here but couldn't get information on props or how transition is handled: Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
In the "use client";
import {
defaultImageSizes
} from "../chunk-UOD2T27N.js";
import "../chunk-MLKGABMK.js";
// src/components/image-zoom.tsx
import Image from "next/image";
import Zoom from "react-medium-image-zoom";
import "../../dist/image-zoom.css";
import { jsx } from "react/jsx-runtime";
function getImageSrc(src) {
if (typeof src === "string") return src;
if ("default" in src) return src.default.src;
return src.src;
}
function ImageZoom({
zoomInProps,
children,
...props
}) {
return /* @__PURE__ */ jsx(
Zoom,
{
zoomMargin: 20,
wrapElement: "span",
zoomImg: {
src: getImageSrc(props.src),
sizes: void 0,
...zoomInProps
},
children: children ?? /* @__PURE__ */ jsx(Image, { sizes: defaultImageSizes, ...props }),
// other properties you want to add
}
);
}
export {
ImageZoom
}; This will change the border while the image is zoomed. |
Beta Was this translation helpful? Give feedback.
Looks like this has been fixed in [email protected], i.e. the code below
Example
style.css
:Example
component.tsx
:Now works as expected. Thanks @fuma-nama and @Gitstar-OC!