0.3.1 • Published 1 year ago

react-image-viewer-hook v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

React Image Viewer Hook (useImageViewer)

Image viewer (aka Lightbox) made for React. Images only (no videos, iframes, custom html, ...), with a focus on touch interactions (swipe between images, pinch to zoom, pan around, swipe down to dismiss). Internal heavy lifting is done by react-spring and use-gesture. Supports code-splitting by default (image viewer code is only loaded once first opened). The image viewer chunk comes at around 37kB gzipped.

Demo: https://codesandbox.io/s/react-image-viewer-hook-demo-6ty7g

Example:

import { useImageViewer } from 'react-image-viewer-hook'
function Page() {
  const { getOnClick, ImageViewer } = useImageViewer()
  return (
    <>
      <a href="image1.jpg" onClick={getOnClick(image1.jpg)}><img src="image1_thumb.jpg" /></a>
      <a href="image2.jpg" onClick={getOnClick(image2.jpg)}><img src="image2_thumb.jpg" /></a>

      <ImageViewer /> {/* can be rendered wherever you want - like in a portal */}
    </>
  )
}

License

MIT

0.3.1

1 year ago

0.3.0

1 year ago

0.1.10

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.1.6

2 years ago

0.2.4

2 years ago

0.1.5

2 years ago

0.1.2

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago