2.0.4 • Published 3 years ago

react-native-image-modal v2.0.4

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

react-native-image-modal

react-native-image-modal is a simple full size modal image for iOS and Android.

You can pinch zoom-in/out, double-tap zoom-in/out, move and swipe-to-dismiss. It supports react version >= 0.60 and <= 0.59.

Document

Expo

This library does not support Expo anymore. Because this library uses react-native-fast-image.

1.0.16 is deprecated, but the version supports Expo.

npm install --save react-native-image-modal@1.0.16

Blog

There are blog posts about how to use react-native-image-modal.

Installation

This library use react-native-fast-image, so you need to install it.

npm install --save react-native-fast-image
npx pod-install

And then execute the command to install react-native-image-modal.

npm install --save react-native-image-modal

How to use

Import react-native-image-modal.

import ImageModal from 'react-native-image-modal';

Add the source code below to where you want to use it.

return (
  <ImageModal
    resizeMode="contain"
    imageBackgroundColor="#000000"
    style={{
      width: 250,
      height: 250,
    }}
    source={{
      uri: 'https://cdn.pixabay.com/photo/2019/07/25/18/58/church-4363258_960_720.jpg',
    }}
  />
);

Properties

You can use All props of React Native Image for the original image(not full size modal image). Below are react-native-image-modal specific properties.

ProprequiredTypeDescription
renderToHardwareTextureAndroidXbooleanIt is for Android animation. Default is true. If you don't want to use Hardware Texture on Android, set false.
isTranslucentXbooleanif you use translucent status bar in android, set true to prevent wrong position animation. (In Expo, translucent default is true)
swipeToDismissXbooleanset true to swipe to dismiss (default: true)
imageBackgroundColorXstringbackground color for the original image
overlayBackgroundColorXstringbackground color for the full size modal(default: #000000)
modalRefXImageDetailYou can use this Ref for closing the Modal programmatically.
disabledXbooleandisable opening the modal
modalImageStyleXImageStyleImage Style in Modal
resizeModeXResizeMode('contain', 'cover', 'stretch','center')Image resizeMode
modalImageResizeModeXResizeMode('contain', 'cover', 'stretch','center')Image resizeMode for modal image. If it is not passed, it will follow the resizeMode.
hideCloseButtonXbooleanhide hide the default close button
onLongPressOriginImageX() => voidlong press event callback for the original image
renderHeaderX(close: () => void) => JSX.You can customize the header of the full size modal with react native components
renderFooterX(close: () => void) => JSX.You can customize the footer of the full size modal with react native components
isRTLXbooleanYou can use this library with right-to-left-devices. (#35)
onTapX(eventParams: {locationX: number; locationY: number; pageX: number; pageY: number;}) => voidone tap event callback for the full size modal
onDoubleTapX() => voiddouble tap event callback for the full size modal
onLongPressX() => voidlong press event callback for the full size modal
onOpenX() => voidopen event callback for the full size modal
didOpenX() => voidevent callback after open for the full size modal
onMoveX(position: {type: string; positionX: number; positionY: number; scale: number; zoomCurrentDistance: number;}) => voidmove event callback for the full size modal
responderReleaseX(vx?: number, scale?: number) => voidresponder release event callback for the full size modal
willCloseX() => voidevent callback before close for the full size modal
onCloseX() => voidclose event callback for the full size modal

Demo

  • Open and close the image modal

open and close image modal

  • pinch zoom in/out and move

pinch zoom in/out and move

  • double tap zoom in/out

double tap zoom in/out

  • swipe to dismiss

swipe to dismiss

  • customize the component with the close button

customize the component

Example code

You can see the example code and demo.

Clone the repository

git clone https://github.com/dev-yakuza/react-native-image-modal.git

Install libraries

cd Example
npm install

# iOS
cd ios
pod install

Execute the example project

# Example folder
# iOS
npm run ios
# Android
npm run android

Contribute

You can follow below to contribute react-native-image-modal.

Clone the repository

git clone https://github.com/dev-yakuza/react-native-image-modal.git

Execute the typescript via npm script

npm install
npm start

Execute the Develop project via the commands below.

cd Develop
npm install

# android
npm run android

# ios
cd ios
pod install
cd ..
npm run ios
2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago