🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

react-image-zoom-in-place

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-image-zoom-in-place

A react component to display zoomable images.

0.1.1
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

react-image-zoom-in-place

A react component to display zoomable images.

The zoom works both on mouse & touchscreen, and is done within the original bounds of the image.

Behavior

Mouse

  • Hover over image to zoom
  • Reset when mouse leaves image boundary
  • Panning the image based on cursor position
  • Scroll to +/- zoom within bounds

Touchscreen

  • Pinch gesture to zoom image
  • Drag to pan image.

Props

NameTypeOptionalDescription
srcstringurl or base64 string for the image
altstringxalt text for the image (using an aria-label)
zoomnumberdefault zoom on mouse hover
maxZoomnumbermaximum allowed zoom muliplication by scroll or touch pinch
stepnumberzoom step on mouse scroll
widthnumberxoverride default width
heightnumberxoverride default height

Width and height parameters are optional, but using them can avoid layout shift when the image loads. If only one is defined, the second one is derived from the image aspect ratio.

Usage

import { ZoomableImage } from "react-image-zoom-in-place";


export default function Home() {
  return (
      <div >
        <ZoomableImage
          src={"<image url or base64 here>"}
          alt="alt text"
          zoom={2}
          maxZoom={10}
          step={0.1}
        />
      </div>
  );
}

License

MIT

Git

https://github.com/MilanFIN/react-image-zoom-in-place

NPM

https://www.npmjs.com/package/react-image-zoom-in-place

FAQs

Package last updated on 11 Nov 2024

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