Last active
October 20, 2022 09:22
-
-
Save MantasMikal/a04b2b6b760ef3ef796a00bd84716160 to your computer and use it in GitHub Desktop.
Easy way to zoom gatsby-image with react-medium-image-zoom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Demo https://guste.design/gallery/ | |
// Install https://www.npmjs.com/package/react-medium-image-zoom | |
// ImageZoom.jsx | |
import React from 'react' | |
import Image from 'gatsby-image' | |
import Zoom from 'react-medium-image-zoom' | |
import styles from './ImageZoom.module.css' | |
import 'react-medium-image-zoom/dist/styles.css' | |
const wrapperStyle = { | |
width: '100%', | |
height: '100%' | |
} | |
const ImageZoom = (props) => { | |
return ( | |
<Zoom> | |
<Image style={wrapperStyle} {...props} /> | |
</Zoom> | |
) | |
} | |
export default ImageZoom | |
// ImageZoom.module.scss | |
:global { | |
[data-rmiz-wrap='visible'], | |
[data-rmiz-wrap='hidden'] { | |
width: 100%; | |
height: 100%; | |
display: block; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm late to the game, but for what it's worth, I believe I've fixed this for
gatsby-plugin-image
in[email protected]
and expect to release it in5.0.2
soon. Here's the issue for tracking purposes: rpearce/react-medium-image-zoom#347Edit:
5.0.2
is now out there