# js-minimap

> Generate a minimap for your web page(or a module).自动生成网页缩略图

Latest version **1.1.1** (published 2024-04-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-minimap
pnpm add js-minimap
yarn add js-minimap
bun add js-minimap
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2024-04-24 |
| First published | 2022-10-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 53.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | hx24 |
| Maintainers | huangxin112 |
| Keywords | minimap, preview, 缩略图, 预览图 |

## Links

- npm: https://www.npmjs.com/package/js-minimap
- Repository: https://github.com/hx24/js-minimap
- Issues: https://github.com/hx24/js-minimap/issues
- npm.io page: https://npm.io/package/js-minimap

## Recent versions

- 1.1.1 (latest) — 2024-04-24
- 1.1.0 — 2024-04-24
- 1.0.7 — 2022-10-20
- 1.0.6 — 2022-10-20
- 1.0.5 — 2022-10-20
- 1.0.4 — 2022-10-19
- 1.0.3 — 2022-10-19
- 1.0.2 — 2022-10-19

## README

# js-minimap

[中文文档](https://github.com/hx24/js-minimap/blob/master/README-CN.md)

Generate a minimap for your web page(or a module), and observe the view to update automatic.

自动生成页面（或局部模块）的缩略图，并可观察视图变化以自动更新缩略图。  

[Demo](https://www.huangxin.fun/static/js-minimap/)

![preview](https://qnm.hunliji.com/FtjaiZMwrepSyKiB33s9KhHrZk9J)

## Installation

### NPM

```javascript
import Minimap from 'js-minimap'
```

### Browser

```html
<script src="js-minimap/dist/minimap.umd.js" />

// cdn
<script src="https://cdn.jsdelivr.net/npm/js-minimap" />
// or
<script src="https://unpkg.com/js-minimap" />
```

## Usage

```html
<div class="container">
  <!-- your content -->
</div>
<div class="minimap"></div>
<script>
  const container = document.querySelector('.container') // any container you want to generate a minimap for
  const target = document.querySelector('.minimap') // the container of the minimap
  const minimap = new Minimap({
    container,
    target,
    width: 200,
    observe: true, // default true
    throttle: 30, // default 30
  })
</script>
```

## Options

| Option    | Description                                                                         | Type        | Default |
| :-------- | :---------------------------------------------------------------------------------- | :---------- | :------ |
| container | any container you want to generate a minimap for                                    | HTMLElement | -       |
| target    | somewhere you want to place the minimap.                                            | HTMLElement | -       |
| width     | minimap's width                                                                     | number      | 200     |
| height    | minimap's height, if `width` is available, `height` will be ignored                 | number      | -       |
| observe   | whether observe the view container to update the minimap, based on MutationObserver | boolean     | true    |
| throttle  | throttle time                                                                       | number      | 30      |

## Methods

### reset

if you want to reset the minimap manually, call `reset` method.

```javascript
const minimap = new Minimap({
  container,
  target,
  observe: false,
})

// when you want to reset the minimap, for example, the container's content changed
minimap.reset()
```

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