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 🙏

© 2025 – Pkg Stats / Ryan Hefner

inner-image-zoom

v1.0.1

Published

A lightweight Vanilla JS package for magnifying an image within its parent container 🔎

Readme

inner-image-zoom

GitHub Actions NPM

A lightweight Vanilla JavaScript package for magnifying an image within its original container.

Demos | Changelog

Installation

NPM

npm install inner-image-zoom

Yarn

yarn add inner-image-zoom

CDN

<script src="https://cdn.jsdelivr.net/npm/[email protected]/umd/index.min.js"></script>

TypeScript

Type declarations were added with version 1.0.0.

Styling

You can download the raw styles.css file or, if your build supports it, import the stylesheet directly from node_modules using:

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

Usage

HTML

Initializing Inner Image Zoom requires an img tag and selector (either custom or the default iiz). The img tag can be standalone:

<img class="iiz" src="/path/to/image-2x.jpg" />

Or in a container:

<div class="iiz">
  <img src="/path/to/image.jpg" />
</div>

Options may be applied to specific instances using data attributes:

<div class="iiz" data-move-type="drag">
  <img src="/path/to/image.jpg" />
</div>

Any content within the container will be preserved. This is useful for responsive images or adding custom image spacers or loading states:

<picture class="iiz" data-zoom-src="/path/to/zoom-image.jpg">
  <source
    srcset="/path/to/large-image.jpg, /path/to/large-image-2x.jpg 2x"
    media="(min-width: 500px)"
  />
  <img
    srcset="/path/to/small-image.jpg, /path/to/small-image-2x.jpg 2x"
    src="/path/to/image.jpg"
  />
</picture>

JS

Start by importing and initializing:

import InnerImageZoom from 'inner-image-zoom';

...

new InnerImageZoom();

You can also initialize with a custom selector or options object:

new InnerImageZoom('.selector', {
  zoomScale: 0.9,
  moveType: 'drag',
  hideCloseButton: true,
  hideHint: true
});

Options

Option | Type | Default | Description --- | --- | --- | --- zoomSrc | string | | URL for the larger zoom image. Falls back to original image src if not defined. zoomScale | number | 1 | Multiplied against the natural width and height of the zoomed image. This will generally be a decimal (example, 0.9 for 90%). zoomPreload | boolean | false | If set to true, preloads the zoom image instead of waiting for mouseenter and (unless on a touch device) persists the image on mouseleave. moveType | pan or drag | pan | The user behavior for moving zoomed images on non-touch devices. zoomType | click or hover | click | The user behavior for triggering zoom. When using hover, combine with zoomPreload to avoid flickering on rapid mouse movements. 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. hideCloseButton | boolean | false | Hides the close button on touch devices. If set to true, zoom out is triggered by tap. hideHint | boolean | false | Hides the magnifying glass hint. afterZoomIn | () => void | | Function to be called after zoom in. afterZoomOut | () => void | | Function to be called after zoom out.

Methods

  • reinit - Reinitialize an InnerImageZoom instance with new options.
  • uninit - Unitialize an InnerImageZoom instance.

Issues

Please submit bugs or requests on the GitHub issues page and make sure to use the vanilla label.

License

MIT