2.1.9 • Published 4 years ago

react-native-image-view v2.1.9

Weekly downloads
1,605
License
MIT
Repository
github
Last release
4 years ago

If you are using React Native >= 0.59.0 I recommend to use the clone of this package https://github.com/jobtoday/react-native-image-viewing as improved and more optimized version!

npm version

React Native modal image view with pinch zoom and carousel.

Try with expo: https://expo.io/@antonkalinin/react-native-image-view

Warning: Breaking changes since v2.0.0:

  • instead of prop source => images
  • no title prop for footer, please use renderFooter instead

Installation

yarn add react-native-image-view

or

npm install --save react-native-image-view

Demo

Usage

import ImageView from 'react-native-image-view';

const images = [
    {
        source: {
            uri: 'https://cdn.pixabay.com/photo/2017/08/17/10/47/paris-2650808_960_720.jpg',
        },
        title: 'Paris',
        width: 806,
        height: 720,
    },
];

<ImageView
    images={images}
    imageIndex={0}
    isVisible={this.state.isImageViewVisible}
    renderFooter={(currentImage) => (<View><Text>My footer</Text></View>)}
/>

See example for better understanding

Props

Prop nameDescriptionTypeDefault valuePlatform
animationTypeType of animation modal presented with"none", "fade", "slide""none"
backgroundColorBackground color of the modal in HEX (#0099CC)stringnull
controlsConfig of available controls (see below)Object{close: true}
glideAlwaysEmulates ScrollView glide animation if built-in was not triggeredbooleanfalseAndroid
glideAlwaysDelayDefines delay in milliseconds for glideAlwaysnumber75Android
imagesArray of images to display, see below image item descriptionarray[]
imageIndexCurrent index of image to displaynumber0
isVisibleIs modal shown or notbooleanfalse
isTapZoomEnabledZoom image when double tappedbooleantrue
isPinchZoomEnabledZoom image with pinch gesturebooleantrue
isSwipeCloseEnabledClose modal with swipe up or downbooleantrue
onCloseFunction called on modal closedfunctionnone
onImageChangeFunction called when image is changedfunctionnone
renderFooterFunction returns a footer elementfunctionnone

Image item:

{
  source: any, // Image Component source object
  width: ?number, // Width of full screen image (optional but recommended)
  height: ?number, // Height of full screen image (optional but recommended)
  // any other props you need to render your footer
}

It's recommended to specify width and height to speed up rendering, overwise component needs to fetch images sizes and cache them in images objects passed as props.

controls prop:

type ControlType = React.Component<{onPress: () => void}> | null | boolean,

{
  close: ControlType // Component for close button in up right corner, as onPress prop accepts function to close modal
  next: ControlType, // Component for next image button, as onPress prop accepts function to scroll to next image
  prev: ControlType, // Component for previous image button, as onPress prop accepts function to scroll to previous image
}

To use default components just set {next: true, prev: true}, close is showing by default. To create custom controls check src/controls.

License

MIT

2.1.9

4 years ago

2.1.8

5 years ago

2.1.7

5 years ago

2.1.6

5 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.12

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

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.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago