react-native-image-zoom-viewer

react native image viewer,大图浏览

react-native-image-zoom-viewer downloads react-native-image-zoom-viewer version react-native-image-zoom-viewer license

react-native-image-zoom-viewerSimilar Packages:
Npm Package Weekly Downloads Trend
3 Years
🌟 Show real-time usage chart on react-native-image-zoom-viewer's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of react-native-image-zoom-viewer](https://npm-compare.com/img/npm-trend/THREE_YEARS/react-native-image-zoom-viewer.png)](https://npm-compare.com/react-native-image-zoom-viewer#timeRange=THREE_YEARS)
Cumulative GitHub Star Trend
🌟 Show GitHub stars trend chart on react-native-image-zoom-viewer's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of react-native-image-zoom-viewer](https://npm-compare.com/img/github-trend/react-native-image-zoom-viewer.png)](https://npm-compare.com/react-native-image-zoom-viewer)
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-native-image-zoom-viewer49,7382,450117 kB194-MIT
README for react-native-image-zoom-viewer

Show Cases

Swiper image

Zoom while sliding

Swipe down

Getting Started

Installation

npm i react-native-image-zoom-viewer --save

Basic Usage

  • Install create-react-native-app first
$ npm install -g create-react-native-app
  • Initialization of a react-native project
$ create-react-native-app AwesomeProject
  • Then, edit AwesomeProject/App.js, like this:
import { Modal } from 'react-native';
import ImageViewer from 'react-native-image-zoom-viewer';

const images = [{
    // Simplest usage.
    url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460',

    // width: number
    // height: number
    // Optional, if you know the image size, you can set the optimization performance

    // You can pass props to <Image />.
    props: {
        // headers: ...
    }
}, {
    url: '',
    props: {
        // Or you can set source directory.
        source: require('../background.png')
    }
}]

export default class App extends React.Component {
    render: function() {
        return (
            <Modal visible={true} transparent={true}>
                <ImageViewer imageUrls={images}/>
            </Modal>
        )
    }
}

Props

parametertyperequireddescriptiondefault
imageUrlsarrayyesImage Source
enableImageZoombooleannoEnable image zoomtrue
onShowModalfunction

(content?: JSX.Element) => void
noThe callback for show modal() => {}
onCancelfunction

() => void
noThe callback for cancel modal() => {}
flipThresholdnumbernoSwipe threshold of the next page80
maxOverflownumbernoThe X position maximum, that current page can slide to the next page300
indexnumbernoInit index of images0
failImageSourcestring, object

{url: string}
noplaceholder for fail''
loadingRenderfunction

() => React.ReactElement<any>
noplaceholder for loading() => null
onSaveToCamerafunction

(index?: number => void
noThe callback for save to camera() => {}
onChangefunction

(index?: number => void
noWhen the image changed() => {}
onMove( position: IOnMove )=>voidreports movement position data (helpful to build overlays)()=> {}
saveToLocalByLongPressbooleannoEnable save to camera when long presstrue
onClickfunction

(onCancel?: function) => void
noOnclick(onCancel) => {onCancel()}
onDoubleClickfunction

(onCancel?: function) => void
noOnDoubleClick(onCancel) => {onCancel()}
onSavefunction

(url: string) => void
noThe picture is saved to the local method, if you write this method will not call the system default method for Android does not support saveToCameraRoll remote picture, you can call this callback in Android call native interface
renderHeaderfunction

(currentIndex?: number) => React.ReactElement<any>
noCustom header() => null
renderFooterfunction

(currentIndex?: number) => React.ReactElement<any>
noCustom footer() => null
renderIndicatorfunction

(currentIndex?: number, allSize?) => React.ReactElement<any>: number
noCustom indicator(currentIndex, allSize) => currentIndex + "/" + allSize
renderImagefunction

(props: any) => React.ReactElement<any>
noCustom image component(props) => <Image {...props} />
renderArrowLeftfunction

() => React.ReactElement<any>
noCustom left arrow() => null
renderArrowRightfunction

() => React.ReactElement<any>
noCustom right arrow() => null
onSwipeDownfunction

() => void
noCallback for swipe down() => null
footerContainerStyleobject

{someStyle: someValue}
nocustom style props for container that will be holding your footer that you passbottom: 0, position: "absolute", zIndex: 9999
backgroundColorstring

white
noComponent background colorblack
enableSwipeDownbooleannoEnable swipe down to close image viewer. When swipe down, will trigger onCancel.false
swipeDownThresholdnumbernoThreshold for firing swipe down function
doubleClickIntervalnumbernoDouble click interval.
pageAnimateTimenumbernoSet the animation time for page flipping.100
enablePreloadbooleannoPreload the next imagefalse
useNativeDriverbooleannoWhether to animate using useNativeDriverfalse
menusfunction

({cancel,saveToLocal}) => React.ReactElement<any>
noCustom menus, with 2 methods:cancel to hide menus and saveToLocal to save image to camera
menuContextobject

{someKey: someValue}
noCustom menu context.{ saveToLocal: 'save to the album', cancel: 'cancel' }

Development pattern

Step 1, run TS listener

After clone this repo, then:

npm install
npm start

Step 2, run demo

cd demo
npm install
npm start

Then, scan the QR, use your expo app.

Dependence

Depend on react-native-image-pan-zoom: https://github.com/ascoders/react-native-image-zoom