GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Mario-Duarte/react-image-zooom: Simple React component that will allow users to zoom in on your images, perfect for product images and galleries!

BranchesTags
Open more actions menu

Latest commit

 

History

137 Commits
137 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.vscode
.vscode
 
 
dist
dist
 
 
src
src
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
.nvmrc
.nvmrc
 
 
CHANGELOG.md
CHANGELOG.md
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
vite.config.ts
vite.config.ts
 
 
vitest.config.ts
vitest.config.ts
 
 

Repository files navigation

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 classes via the theme 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.7.0

  • Improved accessibility: figure now uses role="button" and tabIndex=0 for keyboard navigation.
  • Added theme prop for custom root and image class styling.
  • Enhanced error handling: custom errorContent can be rendered on image load failure.
  • Refactored internal hooks for better testability and maintainability.
  • Updated documentation and examples.

View changelog for previous release notes.

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

Note: CSS is injected automatically with the build. You do not need to import any CSS files manually.

TypeScript: Type definitions are included automatically. No need to install @types/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 (deprecated) Null false
theme undefined false
id Null false
src Null true
zoom 200 false
fullWidth false 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 theme="{{root: "galleryItem", image: "myGalleryImg"}}" src="https://picsum.photos/seed/001/1920/1080" alt="My gallery image 1" zoom="300"/></li>
        <li><ImageZoom theme="{{root: "galleryItem", image: "myGalleryImg"}}" src="https://picsum.photos/seed/002/1920/1080" alt="My gallery image 2" zoom="200"/></li>
        <li><ImageZoom theme="{{root: "galleryItem", image: "myGalleryImg"}}" src="https://picsum.photos/seed/003/1920/1080" alt="My gallery image 3" zoom="200"/></li>
        <li><ImageZoom theme="{{root: "galleryItem", image: "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.

About

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

mario-duarte.github.io/react-image-zooom/

Topics

javascriptreactreactcomponentreactcomponentsreactjs

Resources

Readme
Activity

Stars

29 stars

Watchers

1 watching

Forks

8 forks
Report repository

Releases

Sponsor this project

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.