# text-wrap-px

> 文本断行；不同于字符数的断行，可以根据 CSS 样式以像素级别的断行；

Latest version **0.2.4** (published 2016-09-20) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install text-wrap-px
pnpm add text-wrap-px
yarn add text-wrap-px
bun add text-wrap-px
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2016-09-20 |
| First published | 2016-03-02 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| Author | Wei Fei |
| Maintainers | weifei365 |
| Keywords | text-wrap, text-wrap-css, 断行, html, 断行 |

## Links

- npm: https://www.npmjs.com/package/text-wrap-px
- Repository: https://github.com/WeiFei365/text-wrap-px
- Homepage: https://github.com/WeiFei365/text-wrap-px#readme
- Issues: https://github.com/WeiFei365/text-wrap-px/issues
- npm.io page: https://npm.io/package/text-wrap-px

## Dependencies (1)

- [jquery](https://npm.io/package/jquery.md) ^2.1.4

## Recent versions

- 0.2.4 (latest) — 2016-09-20
- 0.2.3 — 2016-09-18
- 0.2.2 — 2016-09-07
- 0.2.1 — 2016-09-07
- 0.2.0 — 2016-09-06
- 0.1.4 — 2016-04-12
- 0.1.3 — 2016-04-12
- 0.1.2 — 2016-04-07
- 0.1.1 — 2016-03-29
- 0.1.0 — 2016-03-08
- 0.0.7 — 2016-03-07
- 0.0.6 — 2016-03-07
- 0.0.5 — 2016-03-04
- 0.0.4 — 2016-03-03
- 0.0.3 — 2016-03-02
- … 2 more at https://npm.io/package/text-wrap-px/versions

## README

# Text Wrap Pixels(text-wrap-px)

简单来讲，**TextWrapPX** 是一个基于 JavaScript 来精确处理文本断行、截断的小工具；使用场景类似无法直接通过 CSS Style 来控制断行、截断，如：SVG 中的 text 标签，canvas 中的文本换行等等；


* [用法](https://weifei365.gitbooks.io/text-wrap-px/content/usages.html)
* [在线测试](http://weifei365.github.io/text-wrap-px/)
* [Options 配置项](https://weifei365.gitbooks.io/text-wrap-px/content/options.html)
* [API 接口定义](https://weifei365.gitbooks.io/text-wrap-px/content/api_documents.html)
* [其他说明](https://weifei365.gitbooks.io/text-wrap-px/content/tips.html)
* [开发者](https://weifei365.gitbooks.io/text-wrap-px/content/developer.html)


## 一、NPM 安装使用

进入到你的项目根目录，输入以下命令将 **TextWrapPX** 安装到你的项目中：

```bash
npm install --save text-wrap-px
```

【实例方式】安装成功后，在你需要使用的地方这样：

```js
var TextWrapPX = require('text-wrap-px');
var textWrapPXOpts = { maxWidth: [400] };
var textWrapper = new TextWrapPX('', textWrapPXOpts);

// result 是一个数组，result.length 表示文本的行数，result[i] 表示第 i 行的文本
var result = textWrapper.build('Hello text-wrap-px');

// 使用完了以后别忘记销毁
textWrapper.destroy();
```

【方法方式】上面那种是实例的使用方式，如果只是想简单的一次性使用，也可以这样：

```js
var TextWrapPX = require('text-wrap-px');

var result = TextWrapPX('Hello text-wrap-px', { maxWidth: [400] });
```

## License

**text-wrap-px** dependent on some open source licensed projects as well. Please checkout their homepage for more details:

+ [jquery](https://jquery.com/) - jQuery Foundation
+ [lodash](https://lodash.com/) - Dojo Foundation

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