Thanks to visit codestin.com
Credit goes to github.com

Skip to content

@zoomlens/core is a React + Next.js compatible package designed for ecommerce-style product image zoom. It provides developers with a simple, customizable way to add zoom functionality to product images without reinventing the wheel.

Notifications You must be signed in to change notification settings

jahidulsaeid/zoomlens-core

Repository files navigation

@zoomlens/core

A React + Next.js compatible package for ecommerce-style product image zoom with lens, side-by-side preview, and modal functionality.

Features

  • 🔍 Lens Zoom - Amazon-style magnifying lens on hover
  • 🖼️ Side-by-Side Preview - Real-time magnified view in separate container
  • 🎨 Customizable Styling - Support for CSS objects, classes, Tailwind, styled-components
  • Performance Optimized - Lazy loading, efficient re-renders, SSR-friendly
  • 📱 Responsive - Works on desktop and mobile devices
  • 🔧 TypeScript - Full type safety and IntelliSense support

Installation

npm install @zoomlens/core
# or
yarn add @zoomlens/core
# or
pnpm add @zoomlens/core

Quick Start

import { ZoomLens } from '@zoomlens/core';

function ProductImage() {
  return (
    <ZoomLens
      src="/product-image.jpg"
      zoomSrc="/product-image-large.jpg"
      alt="Product image"
    />
  );
}

API Reference

Props

Prop Type Default Description
src string required Main image URL
zoomSrc string src High-resolution zoom image URL
width number | string "auto" Width of main image
height number | string "auto" Height of main image
zoomPosition "left" | "right" | "top" | "bottom" | "original" "right" Where zoomed image appears
zoomWidth number 300 Width of zoom preview
zoomScale number 2 Magnification scale
lensSize number 100 Size of the lens (in px)
lensStyle CSSProperties | string {} Custom CSS for lens
zoomStyle CSSProperties | string {} Custom CSS for zoom container
containerStyle CSSProperties | string {} Custom CSS for main container
offset {x: number, y: number} {x: 0, y: 0} Offset for zoom container
alt string "Zoomable image" Alt text for the image
className string "" CSS class for main container

Examples

Basic Usage

<ZoomLens
  src="/shirt.jpg"
  zoomSrc="/shirt-large.jpg"
  alt="Product shirt"
/>

Custom Styling

<ZoomLens
  src="/watch.jpg"
  zoomSrc="/watch-large.jpg"
  lensSize={120}
  zoomScale={3}
  zoomPosition="left"
  lensStyle={{
    border: "2px solid #000",
    backgroundColor: "rgba(0,0,0,0.2)",
    borderRadius: "50%"
  }}
  zoomStyle={{
    border: "1px solid #ccc",
    borderRadius: "8px"
  }}
/>

With Tailwind CSS

<ZoomLens
  src="/product.jpg"
  className="rounded-lg shadow-lg"
  lensStyle="border-2 border-blue-500 bg-blue-100 bg-opacity-30"
  zoomStyle="border border-gray-300 rounded-lg shadow-xl"
/>

Development

See DEVELOPMENT_GUIDE.md for local development setup and testing instructions.

License

MIT © Jahidul Saeid

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Roadmap

  • Click-to-zoom modal functionality
  • Mouse wheel scroll zoom
  • Touch/pinch zoom for mobile
  • Animation system
  • Accessibility improvements
  • Performance optimizations

About

@zoomlens/core is a React + Next.js compatible package designed for ecommerce-style product image zoom. It provides developers with a simple, customizable way to add zoom functionality to product images without reinventing the wheel.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published