Socket
Socket
Sign inDemoInstall

react-native-image-pan-zoom

Package Overview
Dependencies
514
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-image-pan-zoom

图片手势操作


Version published
Weekly downloads
47K
decreased by-17.9%
Maintainers
1
Install size
65.1 kB
Created
Weekly downloads
 

Readme

Source

Show Cases

Zoom while sliding

3.gif

Intelligent zoom

2.gif

Getting Started

Installation

npm i react-native-image-pan-zoom --save

Basic Usage

  • Install react-native first
$ npm i react-native -g
  • Initialization of a react-native project
$ react-native init myproject
  • Then, edit myproject/index.ios.js, like this:
import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Modal
} from 'react-native';

import ImageZoom from 'react-native-image-pan-zoom';

class ImageZoom 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>
        )
    }
}

AppRegistry.registerComponent('myproject', () => 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
leaveStayTimenumberhow many milliseconds after the finger presses to trigger onClick100
leaveDistancenumberhow 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()=> {}

Keywords

FAQs

Last updated on 15 Sep 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc