react-native-image-pan-zoom vs react-native-image-zoom-viewer
Image Zooming Libraries for React Native Comparison
1 Year
react-native-image-pan-zoomreact-native-image-zoom-viewer
What's Image Zooming Libraries for React Native?

These libraries provide functionalities for zooming and panning images in React Native applications, enhancing user experience by allowing users to interact with images more intuitively. They cater to different use cases and design preferences, making it essential to understand their unique features and capabilities.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-native-image-pan-zoom63,508638-735 years agoISC
react-native-image-zoom-viewer42,7102,449117 kB195-MIT
Feature Comparison: react-native-image-pan-zoom vs react-native-image-zoom-viewer

Image Handling

  • react-native-image-pan-zoom:

    This library allows for seamless zooming and panning of a single image. It supports pinch-to-zoom and double-tap to zoom functionalities, making it easy for users to focus on specific details within an image. The implementation is straightforward, requiring minimal configuration, which is beneficial for quick setups.

  • react-native-image-zoom-viewer:

    This package excels in handling multiple images, allowing users to swipe through a gallery of images. It supports pinch-to-zoom and double-tap gestures as well, but also includes features like image captions and customizable indicators, enhancing the overall user experience.

Customization Options

  • react-native-image-pan-zoom:

    Customization is limited in this library, focusing primarily on basic zoom and pan functionalities. Developers can adjust the scale and bounds of the image but may find it less flexible for more complex requirements.

  • react-native-image-zoom-viewer:

    Offers extensive customization options, including the ability to customize the UI components, animations, and gestures. This flexibility allows developers to tailor the viewer to match the app's design and user experience requirements.

Performance

  • react-native-image-pan-zoom:

    Designed for efficiency, this library performs well with single images, ensuring smooth interactions without significant lag. However, performance may vary with very high-resolution images or complex layouts.

  • react-native-image-zoom-viewer:

    Optimized for handling multiple images, this library maintains performance even when displaying a gallery. It employs lazy loading techniques to improve loading times and responsiveness, especially beneficial for apps with numerous images.

Community and Support

  • react-native-image-pan-zoom:

    This library has a smaller community compared to others, which may result in limited support and fewer updates. However, it is straightforward to implement, making it easier for developers to troubleshoot common issues independently.

  • react-native-image-zoom-viewer:

    With a larger user base and active community, this package benefits from more frequent updates and a wealth of resources, including documentation and community support, making it easier to find solutions and enhancements.

Ease of Use

  • react-native-image-pan-zoom:

    This library is easy to set up and requires minimal code to implement basic functionalities, making it ideal for developers looking for a quick solution without extensive learning.

  • react-native-image-zoom-viewer:

    While slightly more complex due to its additional features, it provides a more comprehensive solution for applications needing advanced image viewing capabilities. Developers may need to invest more time in understanding its API and customization options.

How to Choose: react-native-image-pan-zoom vs react-native-image-zoom-viewer
  • react-native-image-pan-zoom:

    Choose 'react-native-image-pan-zoom' if you need a simple and lightweight solution for zooming and panning images with basic touch gestures. It is ideal for applications that require straightforward image manipulation without extensive customization.

  • react-native-image-zoom-viewer:

    Opt for 'react-native-image-zoom-viewer' if your application demands a more feature-rich image viewer with support for multiple images, swipe gestures, and a more polished user interface. This package is suitable for galleries or applications where users need to view images in a slideshow format.

README for react-native-image-pan-zoom

Show Cases

All Contributors

Zoom while sliding

3.gif

Intelligent zoom

2.gif

Getting Started

Installation

npm i react-native-image-pan-zoom --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 { Image, Dimensions } from 'react-native';
import ImageZoom from 'react-native-image-pan-zoom';

export default class App extends React.Component {
    render: function() {
        return (
            <ImageZoom cropWidth={Dimensions.get('window').width}
                       cropHeight={Dimensions.get('window').height}
                       imageWidth={200}
                       imageHeight={200}>
                <Image style={{width:200, height:200}}
                       source={{uri:'http://v1.qzone.cc/avatar/201407/07/00/24/53b9782c444ca987.jpg!200x200.jpg'}}/>
            </ImageZoom>
        )
    }
}

Document

| Props | Type | Description | DefaultValue | | --- | --- | --- | --- | | cropWidth(required) | number | operating area width | 100 | | cropHeight(required) | number | operating area height | 100 | | imageWidth(required) | number | picture width | 100 | | imageHeight(required) | number | picture height | 100 | | onClick | (eventParams: IOnClick)=>void | onClick | ()=>{} | | onDoubleClick | (eventParams: IOnClick)=>void | onDoubleClick | ()=>{} | | panToMove | boolean | allow to move picture with one finger | true | | pinchToZoom | boolean | allow scale with two fingers | true | | clickDistance | number | how many finger movement can also trigger onClick | 10 | | horizontalOuterRangeOffset | (offsetX?: number)=>void | horizontal beyond the distance, the parent to do picture switching, you can listen to this function. When this function is triggered, you can do the switch operation | ()=>{} | | onDragLeft | ()=>void | trigger to switch to the left of the graph, the left sliding speed exceeds the threshold when triggered | ()=>{} | | responderRelease | (vx: number)=>void | let go but do not cancel | ()=>{} | | maxOverflow | number | maximum sliding threshold | 100 | | longPressTime | number | long press threshold | 800 | | onLongPress | (eventParams: IOnClick)=>void | on longPress | ()=> {} | | doubleClickInterval | number | time allocated for second click to be considered as doublClick event | 175 | | onMove | ( position: IOnMove )=>void | reports movement position data (helpful to build overlays) | ()=> {} | | centerOn | { x: number, y: number, scale: number, duration: number } | if given this will cause the map to pan and zoom to the desired location | undefined | | enableSwipeDown | boolean | for enabling vertical movement if user doesn't want it | false | | enableCenterFocus | boolean | for disabling focus on image center if user doesn't want it | true | | onSwipeDown | () => void | function that fires when user swipes down | null | | swipeDownThreshold | number | threshold for firing swipe down function | 230 | | minScale | number | minimum zoom scale | 0.6 | | maxScale | number | maximum zoom scale | 10 | | useNativeDriver | boolean | Whether to animate using useNativeDriver | false | | onStartShouldSetPanResponder | () => boolean | Override onStartShouldSetPanResponder behavior | () => true | | onMoveShouldSetPanResponder | () => boolean | Override onMoveShouldSetPanResponder behavior | undefined | | onPanResponderTerminationRequest | () => boolean | Override onMoveShouldSetPanResponder behavior | () => false | | useHardwareTextureAndroid | boolean | for disabling rendering to hardware texture on Android | true |

| Method | params | Description | | --- | --- | --- | | reset | | Reset the position and the scale of the image | | resetScale | | Reset the scale of the image | | centerOn | ICenterOn | Centers the image in the position indicated. ICenterOn={ x: number, y: number, scale: number, duration: number } |

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.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Darius

💻

Thomas P.

💻

Juan Di Toro

💻

Alhaytham Elhassan

💻

Alexander Pataridze

💻

Peter Xu

💻

This project follows the all-contributors specification. Contributions of any kind welcome!