JSPM

react-medium-image-zoom

4.0.0-alpha.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 196607
  • Score
    100M100P100Q175282F
  • License BSD-3

Accessible medium.com-style image zoom for React

Package Exports

  • react-medium-image-zoom
  • react-medium-image-zoom/dist/styles.css

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-medium-image-zoom) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

⚠️ WARNING

The master branch currently represents the work-in-progress for version 4.0. It is completely unstable and should not be used by anyone except contributors.

The v4.0 work is being tracked on the project board: https://github.com/rpearce/react-medium-image-zoom/projects/1

The latest stable published version is located on the v3.x branch.

react-medium-image-zoom

All Contributors npm version npm downloads Build Status Coverage Status Maintainability Gitter

This library is a React.js implementation of Medium.com's image zoom that allows for low-resolution and high-resolution images to work together for a “zooming” effect and works regardless of parent elements that have overflow: hidden or parents with transform properties.

As an added bonus, it will let you zoom anything (see the Storybook Examples for more).

Installation

$ npm i react-medium-image-zoom

or

$ yarn add react-medium-image-zoom

Basic Usage

Import the component and the component's CSS and then wrap whatever you want to be "zoomable" with this component:

import React, { useState } from 'react'
import Zoom from 'react-medium-image-zoom'
import 'react-medium-image-zoom/dist/styles.css'

const MyComponent = () => (
  <Zoom>
    <img
      alt="that wanaka tree"
      src="/path/to/thatwanakatree.jpg"
      width="500"
    />
  </Zoom>
)

export default MyComponent

API

You can pass options to the default <Zoom> component (Controlled.js):

Prop Type Required Default Details
closeText String no 'Unzoom Image' Accessible label text for when you want to unzoom
openTextText String no 'Zoom Image' Accessible label text for when you want to zoom
overlayBgColorEnd String no 'rgba(255, 255, 255, 0.95)' Modal overlay background color at end of zoom
overlayBgColorStart String no 'rgba(255, 255, 255, 0)' Modal overlay background color at start of zoom
portalEl Element no document.body DOM Element to which we will append the zoom modal
scrollableEl Window no window DOM Element to which we will listen for scroll events to determine if we should unzoom
transitionDuration Number no 300 Transition duration in milliseconds for the component to use on zoom and unzoom
zoomMargin Number no 0 Offset in pixels the zoomed image should be from the window' boundaries

Contributors

Thanks goes to these wonderful people (emoji key):


Cameron Bothner

💻 📖 🐛 💡 🤔 👀 ⚠️

Jeremy Bini

💻 🐛

ismay

🐛 🤔

Rajit Singh

🐛

Roberto Saccon

🐛

wtfdaemon

🐛

Robert Pearce

💻 💬 ⚠️ 🐛 💡 🎨 👀 🤔 📖

Josh Sloat

🐛 💻 💡 👀 🤔 📖 🎨 💬

Aswin

💬

Alex Shelkovskiy

🐛

Adrian Bindiu

🐛

Kendall Buchanan

🐛

Kaycee

💻

Anuj

🐛 💬

Ludwig Frank

🐛 💻

LX

🐛 🤔

Rosen Tomov

🐛

Tom Moor

💻 🐛

Johan Preynat

💻 🐛

Rahul Gaba

💻 🐛

Spencer Davis

💻 🤔 👀 🎨

dnlnvl

💻

Sean King

🤔

This project follows the all-contributors specification. Contributions of any kind welcome!