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-image-zooom

v1.3.5

Published

[![react-image-zooom](https://nodei.co/npm/react-image-zooom.png)](https://www.npmjs.com/package/react-image-zooom)

Downloads

14,044

Readme

Logo-ImageZooom Image-Zooom a React Component

react-image-zooom

Simple React component that will allow users to zoom in on your images, perfect for product images and galleries!

Small and light weight!

npm version https://img.shields.io/librariesio/release/npm/react-image-zooom https://img.shields.io/github/issues-raw/mario-duarte/react-image-zooom https://img.shields.io/snyk/vulnerabilities/github/mario-duarte/react-image-zooom

View it in action on this demo page! Alternatively on this Pen @CodePen

Buy me a coffee to keep me going!

Why?

As a long user of jQuery I have developed many plugins over the years that have helped me developing solutions faster and more reliably. As I move and transition to React(♥) I wanted some of these to come along with me on this new journey.

I like my plugins(now components) to be as flexible as possible and to not get in the way of the styling of the app/site that is been implemented to and this is no different.

Want to come along on this journey and/or have some great ideas on how to improve this component? Check out the repo here!

How it works?

This component has a very minimal styling footprint only setting the minimum to make it work, in addition you can pass in your own className and id props enabling you to adapt the design to your needs.

For extra customization of the style of this component it will also add some extra classes dynamically depending on its state.

It will have the class loading while the image is been preloaded and loaded once it has been loaded.

Additionally it will have the class fullview while the user has not initiated the zoom and zoomed once the user has taped/clicked in.

New to v1.2.0

As requested by the users, you can now have custom components rendered when the image fails to load and pass in a custom callback to handle the error your own way.

New to v1.3.0

As requested by the users, this is now supported by mobile devices.

How to install

To install this on your project run the following command on your terminal: npm install react-image-zooom

Alternatively you can also install using yarn: yarn add react-image-zooom

How to Use

Here is a basic example of how to import and use this component (View on CodePen):

import React from "react"
import ImageZoom from "react-image-zooom";

function myZoomableImg() {
  return (
    <div>
      <ImageZoom src="https://picsum.photos/seed/000/1920/1080" alt="A image to apply the ImageZoom plugin" zoom="200"/>
    </div>
  );
}

export default myZoomableImg;

This component accepts the following attributes:

| Prop | Default value | required | | --------- | :--------------------------: | -------: | | className | Null | false | | id | Null | false | | src | Null | true | | zoom | 200 | false | | alt | "This is an imageZoom image" | false | | width | "100%" | false | | height | "auto" | false |

As you can see above, it is very similar to the standard <img /> tag, now let's look at a more advanced example of a gallery using the component (View on CodePen).

import React from "react"
import ImageZoom from "react-image-zooom";

function myZoomableImg() {
  return (
    <ul className="myGallery">
        <li><ImageZoom className="myGalleryImg" src="https://picsum.photos/seed/001/1920/1080" alt="My gallery image 1" zoom="300"/></li>
        <li><ImageZoom className="myGalleryImg" src="https://picsum.photos/seed/002/1920/1080" alt="My gallery image 2" zoom="200"/></li>
        <li><ImageZoom className="myGalleryImg" src="https://picsum.photos/seed/003/1920/1080" alt="My gallery image 3" zoom="200"/></li>
        <li><ImageZoom className="myGalleryImg" src="https://picsum.photos/seed/004/1920/1080" alt="My gallery image 4" zoom="300"/></li>
    </ul>
  );
}

export default myZoomableImg;

Note that you can also set different Zoom levels per image. For more examples see this demo page!

Bugs and issues

Please report all bugs and issues here.