npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-photo-view-ex

v1.1.0

Published

Displaying photos with pinch-to-zoom, based on react-native-photo-view

Downloads

4,374

Readme

react-native-photo-view-ex

License npm Version

Provides custom Image view for React Native that allows to perform pinch-to-zoom on images. Works on both iOS and Android.

This component uses PhotoDraweeView for Android and MWPhotobrowser on iOS.

About this fork

This fork is based on the great work of @alwx (Alexander Pantyuhov) and has this changes:

  • Android Build Tools 28.0.3 and targetSdkVersion 28 (configurable).
  • Peer dependent on react-native v0.57 and above.
  • Using the same version of fresco included by react-native.
  • Updated dependencies
  • Changes to gradle config to support the new version.
  • Changes to some properties, mainly androidScaleType replaced by resizeMode.
  • PhotoView as PureComponent.
  • Minor fixes.
  • Typescript definitions.

All this is to adapt it better to my current project (it is not tested on iOS), but feel free to use it.

Usage

import PhotoView from 'react-native-photo-view-ex';

Basics:

  <PhotoView
    source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}}
    minimumZoomScale={0.5}
    maximumZoomScale={3}
    resizeMode="center"
    onLoad={() => console.log("Image loaded!")}
    style={{width: 300, height: 300}}
  />

Properties

| Property | Type | Description |----------|------|------------- | source | Object | The same as source for other React images, except that it does not handle arrays. | loadingIndicatorSource | Object | Similarly to source, but used to render the loading indicator. Must be a local image | fadeDuration | int | Duration of the fade, in milliseconds. | scale | float | Zoom scale | maximumZoomScale | float | The maximum allowed zoom scale. The default value is 3.0 | minimumZoomScale | float | The minimum allowed zoom scale. The default value is 1.0 | resizeMode | String | Android only: One of "center", "contain", "cover", "fitStart", "fitEnd", "stretch". The default is "cover" | style | Array or Object | Subset of react-native style. See index.d.ts | showsHorizontalScrollIndicator | bool | iOS only: When true, shows a horizontal scroll indicator. The default value is true. | showsVerticalScrollIndicator | bool | iOS only: When true, shows a vertical scroll indicator. The default value is true. | zoomTransitionDuration | int | Android only: Double-tap zoom transition duration, in milliseconds.

Events

| Name | Parameter * | Description |------|--------------|------------- | onError | - | Invoked on load error. | onLayout | layout: {x, y, width, height} | Invoked on mount and layout changes. | onLoad | - | Invoked when load completes successfully. | onLoadEnd | - | Invoked when load either succeeds or fails. | onLoadStart | - | Invoked on load start. | onProgress | loaded, total | iOS only: Invoked on download progress. | onScale | scale, scaleFactor, focusX, focusY | Callback function called on scale changes. | onTap | scale, x, y | Callback function called on image tap. | onViewTap | scale, x, y | Callback function called on tap outside of the image.

* In the nativeEvent property.

Compared to react-native-image-zoom

react-native-image-zoom functionality is similar, but there are several major differencies:

  • PhotoView is based on PhotoDraweeView which is the "PhotoView For Fresco". It works better, it supports several important callbacks out-of-box and it is, actually, recommended by Chris Banes, because his PhotoView (base for react-native-image-zoom) doesn't completely support Facebook Fresco.
  • PhotoView has more options like fadeDuration and minimumZoomScale/maximumZoomScale and more important callbacks.
  • PhotoView is written in the same manner as default React Image, and it supports most of the features Image has (the goal is to be fully compaitable with Image and support absolutely everything).
  • It is possible to use PhotoView as a container (currently iOS only)!

Automatic installation

Just two simple steps:

yarn add react-native-photo-view-ex
react-native link react-native-photo-view-ex

Manual installation

Android

  1. Add these lines to android/settings.gradle

    include ':react-native-photo-view-ex'
    project(':react-native-photo-view-ex').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-photo-view-ex/android')
  2. Add the dependency to android/app/build.gradle

    dependencies {
      implementation project(':react-native-photo-view-ex')
    }
  3. Register PhotoViewPackage in your MainApplication.java:

    import io.amarcruz.photoview.PhotoViewPackage;
    
    // ...
    
    public class MainActivity extends ReactActivity {
      // ...
    
      @Override
      protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new PhotoViewPackage() // add this manager
        );
      }
    
      // ...
    }

iOS

  1. Add this line to your podfile

    pod 'react-native-photo-view-ex', path: './node_modules/react-native-photo-view-ex'
  2. Run pod install