0.4.9 • Published 5 months ago

@secretwpn/react-image-zoom v0.4.9

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@secretwpn/react-image-zoom

This is a fork of react-responsive-pinch-zoom-pan by Brad Stiff with slightly changed feature set and converted to TypeScript

It provides a React component rendering an img element with zoom and pan capability using CSS transforms.

Install

npm

npm install @secretwpn/react-image-zoom --save

yarn

yarn add @secretwpn/react-image-zoom

Local

  1. git clone https://github.com/secretwpn/react-responsive-pinch-zoom-pan.git
  2. cd react-responsive-pinch-zoom-pan
  3. npm install
  4. npm start
  5. Browse to http://localhost:3001

Usage

import React from 'react'
import { PinchZoomPanImage } from '@secretwpn/react-image-zoom'

const App = () => {
  return (
    <div style={{ width: '500px', height: '500px' }}>
      <PinchZoomPanImage
        src="http://picsum.photos/750/750"
      />
    </div>
  )
}

API

PropTypeDefaultDescription
initialScalenumber or autoautoThe initial scale of the image. When auto, the image will be proportionally 'autofit' to the container.
minScalenumberautoThe minimum scale to which the image can be zoomed out. When auto, the minimum scale is the 'autofit' scale.
maxScalenumber1The maximum scale to which the image can be zoomed in.
zoomRevisionnumberundefinedZoom level will be reset when this prop is changed
positioncenter or topLefttopLeftPosition of the image relative to the container. Applies when the scaled image is smaller than the container.
doubleTapBehaviorreset or zoomresetWhether to zoom in or reset to initial scale on double-click / double-tap.
imageStyleCSSProperties{}Style to apply to the image, e.g. { opacity: 0.5 }
containerStyleCSSProperties{}Style to apply to the image container div, e.g. { width: '100% }
animatebooleanfalseWhether to enable subtle animation
altstringundefinedSame as alt in regular <img /> tag
srcstringundefinedSame as src in regular <img /> tag
onTransformed({top, left, scale}, imageElement) => voidundefinedCalled after applying image transformation
onImageDimensionsChanged({width, height}) => voidundefinedCalled when image dimensions are changed
onDoubleClick() => voidundefinedCalled on double click
onImageLoaded() => voidundefinedCalled when image is loaded

Development

You're welcome to contribute to react-responsive-pinch-zoom-pan.

To set up the project:

  1. Fork and clone the repository
  2. npm install
  3. npm start

The example page will be available on http://localhost:3001 in watch mode, meaning you don't have to refresh the page to see your changes.

0.4.9

5 months ago

0.4.8

1 year ago

0.4.7

1 year ago

0.4.6

1 year ago

0.4.5

1 year ago

0.4.4

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.21

1 year ago

0.3.20

1 year ago

0.3.17

1 year ago

0.3.15

1 year ago

0.3.14

1 year ago

0.3.13

1 year ago

0.3.12

1 year ago

0.3.11

1 year ago

0.3.10

1 year ago

0.3.9

1 year ago

0.3.8

1 year ago

0.3.7

1 year ago

0.3.6

1 year ago

0.3.5

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago