1.0.0 • Published 9 months ago
react-zoom-smooth v1.0.0
react-zoom-smooth
A lightweight, customizable React wrapper component that provides a smooth zoom-in and zoom-out experience for images. It mimics the zoom effect seen on Medium and is fully configurable with zoom factor, animation duration, and background color.
Installation
You can install the package using npm or yarn:
npm install react-zoom-smooth
or
yarn add react-zoom-smooth
Usage
To use react-zoom-smooth, wrap any image component with ZoomImage
:
import React from "react";
import { ZoomImage } from "react-zoom-smooth";
const App = () => (
<div>
<h1>Zoom Image Example</h1>
<ZoomImage
zoomFactor={2}
duration={0.3}
backgroundColor="rgba(0, 0, 0, 0.8)"
>
<img src="https://example.com/image.jpg" alt="Example Image" />
</ZoomImage>
</div>
);
export default App;
Props
Prop | Type | Default | Description |
---|---|---|---|
zoomFactor | number | 2 | Controls the zoom level applied to the image. |
duration | number | 0.3 | The duration of the zoom-in/out animation in seconds. |
backgroundColor | string | "rgba(0, 0, 0, 0.8)" | Background color of the overlay when zoomed in. |
children | ReactElement | (required) | The image or element that the zoom effect is applied to. |
License
You can use and modify this package as you wish. Feel free to make it yours or contribute!