francoischalifour/medium-zoom
关于
🔎🖼️ 面向 Web 的轻量级图片缩放。零依赖,支持任意框架;通过 shadcn 支持 React。
网站与应用开发实测星标增长
- 24小时
- -1
- 7天
- +1
- 15天
- +1
- 1个月
- +6
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
medium-zoom
Lightweight image zoom for the web. Zero dependencies, any framework, React via shadcn.
JavaScript
Install the package:
npm install medium-zoom
Add an image to your page:
<img src="/photo.jpg" alt="A mountain at sunrise" data-zoomable />
After the image is in the document, initialize the zoom:
import mediumZoom from 'medium-zoom'
mediumZoom('[data-zoomable]')
The standard import includes styles and TypeScript definitions. Click the image to zoom. Click again, press esc, or scroll to close it.
The JavaScript quickstart covers script tags, separate stylesheets, and browser support. See the API reference for selectors, options, methods, and events.
React
In a project configured for shadcn/ui, install the component:
npx shadcn@latest add @medium-zoom/image-zoom
import { ImageZoom } from '@/components/ui/image-zoom'
export function Photo() {
return <ImageZoom src="/photo.jpg" alt="A mountain at sunrise" />
}
The command copies the component and stylesheet into your project and installs medium-zoom. The component provides a keyboard-accessible button and manages zoom state and cleanup.
Follow the React quickstart or use the component reference to customize it.
Guides and examples
The documentation covers HD images, galleries, styling, and the JavaScript and React APIs.
Try these runnable examples:
- Plain JavaScript
- React — use the library directly
- shadcn/ui — use the installable React component
- Angular
- Vue
- Svelte
- Astro
- VitePress
Contributing
See the contributing guide to get started.
License
MIT © François Chalifour
探索相关项目
加载中…
