Skip to content

Instantly share code, notes, and snippets.

@MantasMikal
Last active October 20, 2022 09:22
Show Gist options
  • Save MantasMikal/a04b2b6b760ef3ef796a00bd84716160 to your computer and use it in GitHub Desktop.
Save MantasMikal/a04b2b6b760ef3ef796a00bd84716160 to your computer and use it in GitHub Desktop.
Easy way to zoom gatsby-image with react-medium-image-zoom
// 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;
}
}
@rpearce
Copy link

rpearce commented Aug 21, 2022

I'm late to the game, but for what it's worth, I believe I've fixed this for gatsby-plugin-image in react-medium-image-zoom@5.0.2-beta.0 and expect to release it in 5.0.2 soon. Here's the issue for tracking purposes: rpearce/react-medium-image-zoom#347

Edit: 5.0.2 is now out there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment