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

@synconset/react-native-image-zoom

Package Overview
Dependencies
Maintainers
19
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@synconset/react-native-image-zoom

react native image pan zoom

  • 3.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
41
decreased by-44.59%
Maintainers
19
Weekly downloads
 
Created
Source

React Native Image Zoom

This is a fork of a fork that works reasonably well with react-native-snap-carousel. Only forked because the original fork did not publish to npm and I'm not willing to depend on the master branch of someone else's repository. More info on this code can be found here: https://github.com/archriss/react-native-snap-carousel/issues/264

Show Cases

Zoom while sliding

3.gif

Intelligent zoom

2.gif

Getting Started

Installation

npm i @synconset/react-native-image-zoom --save

or

yarn add @synconset/react-native-image-zoom

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

PropsTypeDescriptionDefaultValue
cropWidth(required)numberoperating area width100
cropHeight(required)numberoperating area height100
imageWidth(required)numberpicture width100
imageHeight(required)numberpicture height100
onClick()=>voidonClick()=>{}
panToMovebooleanallow to move picture with one fingertrue
pinchToZoombooleanallow scale with two fingerstrue
clickDistancenumberhow many finger movement can also trigger onClick10
horizontalOuterRangeOffset(offsetX?: number)=>voidhorizontal 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()=>voidtrigger to switch to the left of the graph, the left sliding speed exceeds the threshold when triggered()=>{}
responderRelease(vx: number)=>voidlet go but do not cancel()=>{}
maxOverflownumbermaximum sliding threshold100
longPressTimenumberlong press threshold800
onLongPress()=>voidon longPress()=> {}
doubleClickIntervalnumbertime allocated for second click to be considered as doublClick event175
onMove( position: IOnMove )=>voidreports 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 locationundefined
enableSwipeDownbooleanfor enabling vertical movement if user doesn't want itfalse
enableHorizontalBouncebooleanfor enabling bouncing back to image when overscrolling horizontallyfalse
enableCenterFocusbooleanfor disabling focus on image center if user doesn't want ittrue
onSwipeDown() => voidfunction that fires when user swipes downnull
swipeDownThresholdnumberthreshold for firing swipe down function230
minScalenumberminimum zoom scale0.6
maxScalenumbermaximum zoom scale10
MethodparamsDescription
resetReset the position and the scale of the image
resetScaleReset the scale of the image
centerOnICenterOnCenters 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.

Keywords

FAQs

Package last updated on 21 Sep 2023

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