All Projects → sylvaindubus → React Prismazoom

sylvaindubus / React Prismazoom

Licence: other
A pan and zoom component for React, using CSS transformations.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Prismazoom

react-quick-pinch-zoom
A react component that providing multi-touch gestures for zooming and dragging on any DOM element.
Stars: ✭ 124 (+327.59%)
Mutual labels:  react-component, zoom, pinch-to-zoom
React Native Image View
Modal component to view images with zoom
Stars: ✭ 273 (+841.38%)
Mutual labels:  pinch-to-zoom, zoom
ZoomMarker
A jQuery plugin for scrolling and zooming in and out of the image
Stars: ✭ 81 (+179.31%)
Mutual labels:  pan, zoom
Flutter advanced networkimage
flutter advanced network image provider
Stars: ✭ 282 (+872.41%)
Mutual labels:  zoom, pan
core
Renderer for tldraw and maybe you, too.
Stars: ✭ 418 (+1341.38%)
Mutual labels:  pan, zoom
react-sweet-progress
A way to quickly add a progress bar to react app 🌈
Stars: ✭ 250 (+762.07%)
Mutual labels:  css3, react-component
react-pinch-and-zoom
A react container component with pinch-to-zoom gesture interaction.
Stars: ✭ 33 (+13.79%)
Mutual labels:  react-component, pinch-to-zoom
Any Touch
👋 手势库, 按需2kb~5kb, 兼容PC / 移动端
Stars: ✭ 567 (+1855.17%)
Mutual labels:  drag, pan
React Use Gesture
👇Bread n butter utility for component-tied mouse/touch gestures in React and Vanilla Javascript.
Stars: ✭ 5,704 (+19568.97%)
Mutual labels:  drag, zoom
Chartjs Plugin Zoom
Zoom and pan plugin for Chart.js
Stars: ✭ 404 (+1293.1%)
Mutual labels:  zoom, pan
react-easy-panzoom
Wrapper to enable pan and zoom features for any React component
Stars: ✭ 69 (+137.93%)
Mutual labels:  pan, zoom
Zoomlayout
2D zoom and pan behavior for View hierarchies, images, video streams, and much more, written in Kotlin for Android.
Stars: ✭ 688 (+2272.41%)
Mutual labels:  pinch-to-zoom, pan
svg-pan-zoom-container
A vanilla-js module for adding zoom-on-wheel and pan-on-drag behavior to inline SVG elements.
Stars: ✭ 31 (+6.9%)
Mutual labels:  pan, zoom
use-gesture
👇Bread n butter utility for component-tied mouse/touch gestures in React and Vanilla Javascript.
Stars: ✭ 6,624 (+22741.38%)
Mutual labels:  drag, zoom
react-instagram-zoom-slider
🌄↔️ A slider component with pinch to zoom capabilities inspired by Instagram
Stars: ✭ 67 (+131.03%)
Mutual labels:  zoom, pinch-to-zoom
Zoomage
A simple pinch-to-zoom ImageView library for Android
Stars: ✭ 211 (+627.59%)
Mutual labels:  pinch-to-zoom, zoom
React Native Zoomable View
A view component for react-native with pinch to zoom, tap to move and double tap to zoom capability.
Stars: ✭ 152 (+424.14%)
Mutual labels:  pinch-to-zoom, zoom
Atgmediabrowser
Image slide-show viewer with multiple predefined transition styles, with ability to create new transitions with ease.
Stars: ✭ 186 (+541.38%)
Mutual labels:  pinch-to-zoom, zoom
React Tabtab
💃 Make your react tab dance🕺
Stars: ✭ 347 (+1096.55%)
Mutual labels:  react-component, drag
React Svg Pan Zoom
👀 A React component that adds pan and zoom features to SVG
Stars: ✭ 569 (+1862.07%)
Mutual labels:  zoom, pan

react-prismazoom

About

A pan and zoom component for React, using CSS transformations.

Depends only upon prop-types, react and react-dom modules.
Works on both desktop and mobile.

Online demo here!

Zoom features 🔎

  • Zoom with the mouse-wheel or a two-finger pinch
  • Zoom using double-click or double-tap
  • Zoom on selected area and center

Pan features 👆

  • Pan with the mouse pointer or with one finger when zoomed-in
  • Intuitive panning depending on available space when zoomed-in
  • Adjusts cursor style to indicate in which direction the element can be moved

Breaking changes on v2

  • The package now requires React v16.3 or higher (in order to use react references)
  • The zoom feature through gestures or mousewheel got some improvements to react better with all devices. You may need to adjust the scrollVelocity property passed to the component in order to keep the same effect.

Installation

Install the component

$ npm i -D react-prismazoom

Install the example project

This project includes a full-featured application example.

First clone the project.

Then, install it:

$ npm i

Run the Webpack Dev Server:

$ npm run start

Go to http://localhost:1664.

Note: sources of this example can be found in example/src.

Run unit tests

You can either run all tests at once:

$ npm test

Or run tests each time a change on source files occured:

$ npm run test:watch

Usage

Implementation

import PrismaZoom from 'react-prismazoom'

<PrismaZoom>
  <img src="my-image.png" />
  <p>A text that can be zoomed and dragged</p>
</PrismaZoom>

Props

Name Type Default Description
className string None Class name to apply on the zoom wrapper.
style object None Style to apply on the zoom wrapper. Note that transform, transition, cursor, touch-action and will-change cannot be overridden. Example: style={{backgroundColor: 'red'}}.
minZoom number 1 Minimum zoom ratio.
maxZoom number 5 Maximum zoom ratio.
scrollVelocity number 0.1 Zoom increment or decrement on each scroll wheel detection.
onZoomChange function null Function called each time the zoom value changes.
onPanChange function null Function called each time the posX or posY value changes (aka images was panned).
leftBoundary number 0 Left screen-relative boundary, used to limit panning zone.
rightBoundary number 0 Right screen-relative boundary, used to limit panning zone.
topBoundary number 0 Top screen-relative boundary, used to limit panning zone.
bottomBoundary number 0 Bottom screen-relative boundary, used to limit panning zone.
animDuration number 0.25 Animation duration (in seconds).
doubleTouchMaxDelay number 300 Max delay between two taps to consider a double tap (in milliseconds).
decelerationDuration number 750 Decelerating movement duration after a mouse up or a touch end event (in milliseconds).

Note: all props are optional.

Public methods

These functions can be called from parent components.

zoomIn (value)
Increments the zoom with the given value.
Param {value: Number} : Zoom value

zoomOut (value)
Decrements the zoom with the given value.
Param {value: Number} : Zoom value

zoomToZone (relX, relY, relWidth, relHeight)
Zoom-in on the specified zone with the given relative coordinates and dimensions.
Param {relX: Number} : Relative X position of the zone left-top corner in pixels
Param {relY: Number} : Relative Y position of the zone left-top corner in pixels
Param {relWidth: Number} : Zone width in pixels
Param {relHeight: Number} : Zone height in pixels

reset ()
Resets the component to its initial state.

getZoom ()
Returns the current zoom value.
Return {Number} : Zone value

License

React PrismaZoom is licensed under the ISC license. See the LICENSE.md file for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].