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

@ttatpuot/react-inner-image-zoom

v1.0.6

Published

A React component for magnifying an image within its original container.

Downloads

4

Readme

react-inner-image-zoom

Demos

A React component for magnifying an image within its original container. The zoom behavior is triggered on click and the image can be moved by dragging on touch devices and by either dragging or hover panning on non-touch devices. The component supports responsive images and optional fullscreen zoom on mobile.

Travis npm package

Installation

NPM

npm install react-inner-image-zoom

Yarn

yarn add react-inner-image-zoom

Styling

I was originally importing the CSS directly into the component but I've recently realized that makes too many assumptions about the wider build process. You can now download the raw CSS file at:

/src/InnerImageZoom/styles.css

or the minified raw minified version at:

/src/InnerImageZoom/styles.min.css

to include however you see fit. Or, if your setup supports it, import the files directory from your node_modules using:

import 'react-inner-image-zoom/lib/InnerImageZoom/styles.css';

or:

import 'react-inner-image-zoom/lib/InnerImageZoom/styles.min.css';

Usage

Import and render the component:

import InnerImageZoom from 'react-inner-image-zoom';

...

<InnerImageZoom src="/path/to/image.jpg" zoomSrc="/path/to/zoom-image.jpg" />

This is the simplest usage. For additional examples, visit the demo page.

Props

Prop | Type | Default | Description --- | --- | --- | --- src | String | | (Required) URL for the original image. srcSet | String | | Default srcset attribute for a responsive original image. sizes | String | | Default sizes attribute for use with srcset. sources | Array | | A list of image sources for using the picture tag to serve the appropriate original image (see below for more details). zoomSrc | String | | URL for the larger zoom image. Falls back to original image src if not defined. alt | String | | Alternative text for the original image. moveType | String | pan | pan or drag. The user behavior for moving zoomed images on non-touch devices. zoomType | String | click | click or hover. The zoom behavior for images. fadeDuration | Number | 150 | Fade transition time in milliseconds. If zooming in on transparent images, set this to 0 for best results. fullscreenOnMobile | Boolean | false | Enables fullscreen zoomed image on touch devices below a specified breakpoint. mobileBreakpoint | Number | 640 | The maximum breakpoint for fullscreen zoom image when fullscreenOnMobile is true. className | String | | Custom classname for styling the component. afterZoomIn | Function | | Function to be called after zoom in. afterZoomOut | Function | | Function to be called after zoom out.

Sources

This prop accepts an array of objects which it uses to create a picture tag and source elements. The component looks for the following optional properties and you can find additional details on responsive images here:

Prop | Type | Default | Description --- | --- | --- | --- srcSet | String | | Srcset attribute for source tag. sizes | String | | Sizes attribute for source tag. media | String | | An attribute containing a media condition for use with the srcset. type | String | | An image MIME type. This is useful for using newer formats like WebP.

Issues

Please submit issues or requests here.

Most of the implementation choices for this component are based on use cases I've encountered in the past. For example, I chose a click to zoom trigger because it's been the most requested on product detail pages I've worked on. If there's a demand for zoom on hover or other additional functionality, I'd be open to looking into it so feel free to ask.

License

MIT