Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/timc1/react-fullscreen-image

An accessible, fast, and snappy fullscreen React image viewer.
https://github.com/timc1/react-fullscreen-image

animation css dom hooks javascript react

Last synced: 2 months ago
JSON representation

An accessible, fast, and snappy fullscreen React image viewer.

Awesome Lists containing this project

README

        


React Fullscreen Image



🔲



A simple, fast, and beautiful fullscreen React image viewer using CSS transforms & opacity.


demo

You've got a list of images that you want to allow users to click and expand into fullscreen mode.

React Fullscreen Image is a tiny library to render images that animate to fullscreen view when
clicked.

A live demo can be viewed on [CodeSandbox](https://codesandbox.io/s/o9m59jj3oq)!

## Features

- Only animates transform and opacity properties.
- Keyboard event handlers (escape key, left/right arrow navigation).
- Handles outer click — anywhere outside of image when clicked will zoom image to its original
position.
- Scrolling (with requestAnimationFrame) to a set boundary will zoom image to its original position.

## Usage

React Fullscreen Image uses [compound components](https://kentcdodds.com/blog/compound-components-with-react-hooks). All `` components nested within an `` will be navigatable when in fullscreen mode.

```jsx
import { ImageGroup, Image } from 'react-fullscreen-image'

const images = [
'some_image_url',
'some_image_url',
'some_image_url',
'some_image_url'
]

export default function App() {
return (


    {images.map(i => (



  • ))}


)
}
```

## Installation

```jsx
git clone https://github.com/timc1/react-fullscreen-image.git

cd react-fullscreen-image/example

yarn install

yarn start
```