Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fwon/react-native-image-zoom-viewer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fwon/react-native-image-zoom-viewer

react native image viewer,大图浏览

  • 3.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

Keywords

FAQs

Package last updated on 22 Sep 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc