You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

react-native-image-zoom-viewer

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-image-zoom-viewer

react native image viewer,大图浏览

2.0.20
Source
npm
Version published
Weekly downloads
36K
-12.77%
Maintainers
1
Weekly downloads
 
Created
Source

Show Cases

Swiper image

1.gif

Zoom while sliding

2.gif

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 = [{
    url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460'
}, {
    url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460'
}, {
    url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460'
}]

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() => {}
onCancelfuncion

() => 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

{uri: 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() => {}
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

() => React.ReactElement<any>
noCustom header() => null
renderFooterfunction

() => React.ReactElement<any>
noCustom footer() => null
renderIndicatorfunction

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

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

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

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

Keywords

image-viewer

FAQs

Package last updated on 22 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts