# humming-preview

> 极简轻量级图片预览插件

Latest version **0.0.12** (published 2024-03-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install humming-preview
pnpm add humming-preview
yarn add humming-preview
bun add humming-preview
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.12 |
| Published | 2024-03-05 |
| First published | 2022-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 88.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | itlzi |
| Keywords | humming, 图片预览 |

## Links

- npm: https://www.npmjs.com/package/humming-preview
- Repository: https://github.com/itlangzi/humming-preview
- Homepage: https://github.com/itlangzi/humming-preview#readme
- Issues: https://github.com/itlangzi/humming-preview/issues
- npm.io page: https://npm.io/package/humming-preview

## Recent versions

- 0.0.12 (latest) — 2024-03-05
- 0.0.11 — 2024-02-02
- 0.0.10 — 2024-01-22
- 0.0.9 — 2024-01-22
- 0.0.8 — 2024-01-14
- 0.0.7 — 2023-03-08
- 0.0.6 — 2023-03-08
- 0.0.5 — 2023-02-28
- 0.0.4 — 2023-02-28
- 0.0.3 — 2023-02-28
- 0.0.2 — 2022-08-01
- 0.0.1 — 2022-07-30

## README

# humming
**极简轻量级图片预览插件**  
- [开箱即用](#开箱即用)
- 支持放大、缩小、拖拽、旋转  
- 支持上一个下一个
- [支持键盘快捷键](#键盘快捷键)
- 支持移动端  
- [支持自定义预览](#自定义预览)

[在线预览](https://itlangzi.com/gallery.html)  

# 使用

## 浏览器
```html
<script src="<path>/lib/umd/index.js" ></script>
<script>
    new Humming()
</script>
```
## require/import

```js
import Humming from 'humming-preview'
// const humming = require('humming-preview')
new Humming()
```

# API
```js
new Humming([selector, mount])
```

# 参数

## `selector` 
`[可选]` 待预览的图片选择器  
类型: `string | HTMLElement | Array<HTMLElement>`  
默认: `document.querySelectorAll("img")`  

## `mount`
`[可选]` 挂载的点  
类型: `HTMLElement`  
默认：`document.body`

# 开箱即用
- 设置 `data-humming` 属性
> 将会自动读取所有的图片 `document.querySelectorAll("[data-humming] img")`
- 设置 `data-humming-img` 属性
> 将会自动读取所有的图片  `document.querySelectorAll("[data-humming-img]")`  

***注意*** 
1. 若两种方式出现交叉将会自动去重
2. `开箱即用` 为可选方案
3. 元素不一定是`img`标签, 非`img`标签需要要设置`data-preview`或`data-src`指向预览的图片地址
4. 优先级: `data-preview` > `data-src` > `img.src`


# 键盘快捷键
- 上一个：↑
- 下一个：↓
- 放大：+
- 缩小：-
- 鼠标滚轮：放大缩小

# 自定义预览
在非`img`标签设置`data-preview`或`data-src`指向预览的图片地址

# License
MIT license

---
_Source: https://npm.io/package/humming-preview · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
