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

zphotozoom

v2.0.4

Published

A modern, lightweight TypeScript library for interactive image zoom viewers with touch and mouse support

Readme

zPhotoZoom

npm version License: MIT TypeScript

A modern, lightweight TypeScript library for creating interactive image zoom viewers with seamless touch and mouse support.

✨ Features

  • 🖱️ Mouse Wheel Zoom - Smooth zooming with configurable limits
  • 👆 Touch Gestures - Pinch-to-zoom and drag-to-pan on mobile devices
  • 📱 Responsive Design - Automatic repositioning on window resize
  • Performance - GPU-accelerated transforms for smooth 60fps animations
  • 🎨 Customizable - Configurable zoom limits and container modes
  • 📦 Lightweight - ~15KB minified + gzipped
  • 🔧 TypeScript - Full type definitions included
  • 🎯 Zero Dependencies - No external libraries required
  • Accessible - Keyboard navigation ready (coming soon)
  • 🌐 Browser Support - Works on all modern browsers

📦 Installation

NPM

npm install zphotozoom

Yarn

yarn add zphotozoom

🚀 Quick Start

Basic Usage

<!DOCTYPE html>
<html>
<head>
  <title>zPhotoZoom Demo</title>
</head>
<body>
  <img src="image.jpg" class="zoomable" alt="Zoomable Image">
  
  <script type="module">
    import zPhotoZoom from 'zphotozoom';
    
    const viewer = new zPhotoZoom({
      el: '.zoomable',
      min: 0.5,
      max: 5
    });
  </script>
</body>
</html>

With TypeScript

import zPhotoZoom, { zPhotoZoomOptions, ViewerEvent } from 'zphotozoom';

const options: zPhotoZoomOptions = {
  el: '.gallery-image',
  min: 0.3,
  max: 10
};

const viewer = new zPhotoZoom(options);

// Event listeners
viewer.onOpen((event: ViewerEvent) => {
  console.log('Image opened:', event.target);
});

viewer.onClose((event: ViewerEvent) => {
  console.log('Image closed:', event.target);
});

📖 API Documentation

Constructor

new zPhotoZoom(options?: zPhotoZoomOptions, context?: Document)

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | el | string | required | CSS selector for target images | | container | HTMLElement | undefined | Optional container for embedded mode | | min | number | 0.3 | Minimum zoom scale limit | | max | number | 5 | Maximum zoom scale limit |

Methods

onOpen(callback, remove?)

Register a callback when the viewer opens.

viewer.onOpen((event) => {
  console.log('Viewer opened for:', event.target);
});

onClose(callback, remove?)

Register a callback when the viewer closes.

viewer.onClose((event) => {
  console.log('Viewer closed');
});

stop()

Stops all interactions (zoom, pan, etc.).

viewer.stop();

resume()

Resumes interactions after being stopped.

viewer.resume();

reset()

Resets the current image to its original centered state.

viewer.reset();

close()

Closes the viewer if currently open.

viewer.close();

update()

Forces an update of the image scale and position.

viewer.update();

change(selector)

Changes the target selector and reinitializes images.

viewer.change('.new-selector');

🎨 Usage Examples

Multiple Images Gallery

<div class="gallery">
  <img src="photo1.jpg" class="zoomable" alt="Photo 1">
  <img src="photo2.jpg" class="zoomable" alt="Photo 2">
  <img src="photo3.jpg" class="zoomable" alt="Photo 3">
</div>

<script type="module">
  import zPhotoZoom from 'zphotozoom';
  
  const gallery = new zPhotoZoom({
    el: '.zoomable',
    min: 0.5,
    max: 8
  });
</script>

Embedded Container Mode

<div id="image-container">
  <img src="product.jpg" class="product-image" alt="Product">
</div>

<script type="module">
  import zPhotoZoom from 'zphotozoom';
  
  const container = document.getElementById('image-container');
  
  new zPhotoZoom({
    el: '.product-image',
    container: container
  });
</script>

Dynamic Image Loading

import zPhotoZoom from 'zphotozoom';

const viewer = new zPhotoZoom({ el: '.dynamic-image' });

// Load new images dynamically
fetch('/api/images')
  .then(response => response.json())
  .then(images => {
    const container = document.querySelector('.image-grid');
    
    images.forEach(img => {
      const element = document.createElement('img');
      element.src = img.url;
      element.className = 'dynamic-image';
      container.appendChild(element);
    });
    
    // Reinitialize viewer with new images
    viewer.change('.dynamic-image');
  });

Event Handling

import zPhotoZoom from 'zphotozoom';

const viewer = new zPhotoZoom({ el: '.image' });

// Track analytics
viewer.onOpen((event) => {
  analytics.track('Image Viewed', {
    imageUrl: event.target.src,
    timestamp: Date.now()
  });
});

// Prevent closing in certain conditions
viewer.onClose((event) => {
  if (shouldPreventClose()) {
    event.preventDefault();
  }
});

Programmatic Control

import zPhotoZoom from 'zphotozoom';

const viewer = new zPhotoZoom({ el: '.controlled-image' });

// Pause interactions during video playback
video.addEventListener('play', () => {
  viewer.stop();
});

video.addEventListener('pause', () => {
  viewer.resume();
});

// Reset zoom on specific events
document.querySelector('.reset-btn').addEventListener('click', () => {
  viewer.reset();
});

// Close viewer programmatically
document.querySelector('.close-btn').addEventListener('click', () => {
  viewer.close();
});

🎯 Advanced Configuration

Custom Zoom Limits

// Very restricted zoom
const restrictedViewer = new zPhotoZoom({
  el: '.image',
  min: 0.8,
  max: 2
});

// Extreme zoom capability
const detailViewer = new zPhotoZoom({
  el: '.detailed-image',
  min: 0.1,
  max: 20
});

Multiple Instances

// Different galleries with different settings
const thumbnailViewer = new zPhotoZoom({
  el: '.thumbnail',
  min: 1,
  max: 3
});

const fullsizeViewer = new zPhotoZoom({
  el: '.fullsize',
  min: 0.5,
  max: 10
});

🌐 Browser Support

| Browser | Version | |---------|---------| | Chrome | Last 2 versions | | Firefox | Last 2 versions | | Safari | Last 2 versions | | Edge | Last 2 versions | | iOS Safari | 12+ | | Chrome Android | Last 2 versions |

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Inspired by Google Picasa style
  • Built with TypeScript and modern web standards

🗺️ Roadmap

  • [ ] Keyboard navigation support
  • [ ] ARIA attributes for accessibility
  • [ ] Image rotation support
  • [ ] Gallery navigation (prev/next)
  • [ ] Thumbnail strip in viewer
  • [ ] Virtual scrolling for large galleries
  • [ ] Animation easing configuration
  • [ ] Plugin system for extensibility

Made with ❤️ by AMGHAR Abdeslam