3.0.0-beta.2 • Published 3 years ago

react-imageslides v3.0.0-beta.2

Weekly downloads
157
License
MIT
Repository
github
Last release
3 years ago

React Image Viewer

version

React-slides@3 has been rewriten with React Hooks and all apis of it have been redesigned. If you are using React-slides@2, please read api docs carefully.

Example

demo

Edit focused-resonance-oxzgn

Features

  • Support multi-touch and mouse gestures (powered by Alloyfinger)
  • High performance(no unneccessary rendering)

Get Started

  1. Run yarn add react-imageslides react react-dom alloyfinger

    The package has peer dependencies on react@^17.0.0, react-dom@^17.0.0, and alloyfinger.

  2. Render it!

import React, { useState, useCallback } from 'react';
import ReactDOM from 'react-dom';
import Gallery from 'react-imageslides';
import 'react-imageslides/lib/index.css';

const images = [
  'http://dingyue.nosdn.127.net/0UDLpU6BsCNm9v9OpT0Dhn=nHKJFC6SMByz8bMWxFM=1t1531988836046compressflag.jpeg',
  'http://dingyue.nosdn.127.net/9sFTTWDQoHjxyIkU9wzm8CiDNVbq48Mwf2hyhgRghxA5O1527909480497compressflag.jpeg',
  'http://dingyue.nosdn.127.net/eSJPDtcP9NBvEOIMPyPLxwpJSZIu4D36qDss2RGQjNHBp1531990042001compressflag.jpeg',
  'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503235534249&di=4c198d5a305627d12e5dae4c581c9e57&imgtype=0&src=http%3A%2F%2Fimg2.niutuku.com%2Fdesk%2Fanime%2F0529%2F0529-17277.jpg',
];
export default function App() {
  const [activeIndex, setActiveIndex] = useState(0);

  const handleChange = useCallback(newIndex => {
    setActiveIndex(newIndex);
  }, []);
  return <Gallery isOpen images={images} index={activeIndex} onChange={handleChange} />;
}
ReactDOM.render(<App />, document.getElementById('root'));

Apis

PropertyTypeRequiredDescription
imagesarrayyesImage urls to display
onChangefuncyesCallback fired when the index changes
isOpenboolyesWhether the component is open
indexnumberyesIndex of the first image to display
loadingIconnodePlaceholder when image is loading
onClickfuncCallback fired when user clicks gallery
onKeyPressfuncCallback fired when user press down any key
onSingleTapfuncCallback fired when user taps gallery
imageRendererfuncRender prop to custom image element
3.0.0-beta.2

3 years ago

3.0.0-beta.1

3 years ago

3.0.0-beta.0

3 years ago

2.2.0

3 years ago

2.1.1

3 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.8.7

6 years ago

0.8.6

6 years ago

0.8.5

6 years ago

0.8.4

6 years ago

0.8.3

6 years ago

0.8.2

6 years ago

0.8.1

6 years ago

0.8.0

6 years ago

0.7.3

6 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.3

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.1

7 years ago