Skip to content

Commit aab5447

Browse files
author
🦄 Mater
committed
Init commit
0 parents  commit aab5447

15 files changed

+3068
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
node_modules
3+
dist

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry = "https://registry.npmjs.com/"

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
node_js:
3+
- '11'
4+
- '10'
5+
- '8'
6+
- '6'

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Mater1996
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# EllipsisText
2+
3+
> A generator that gets the minimum content that corresponds to the height of an element
4+
5+
![](header.png)
6+
7+
## Installation
8+
9+
npm:
10+
11+
```sh
12+
npm install omit --save-dev
13+
```
14+
15+
## Usage example
16+
17+
```js
18+
import EllipsisText from 'ellipsis-text'
19+
new EllipsisText(dom, {
20+
str:
21+
'Fame,wealth and knowledge are merely worldly possessions that are withinthe reach of anybodyFame,wealth and knowledge are merely worldly possessions that are withinthe reach of anybodyFame',
22+
callback:function(res){
23+
console.log(res)
24+
// output:Fame,wealth and knowledge are merely worldly possessions that are withinthe reach of anybodyFame,wealth and knowled
25+
}
26+
})
27+
```
28+
29+
## EllipsisText API
30+
31+
```js
32+
new EllipsisText(
33+
HTMLElement,
34+
{
35+
str: String,
36+
rows: Number,
37+
callback:function(res){}
38+
})
39+
```
40+
41+
## Tips
42+
43+
EllipsisText used canvas to determine the number of lines to be intercepted
44+
45+
If you pass in HTML, it deletes the nodes one by one to find the last text node that exceeds the height
46+
47+
## Perfonmance
48+
49+
The following is an EllipsisText performance test (in ms)
50+
51+
![](performance.jpg)
52+
53+
54+
## Development setup
55+
56+
```sh
57+
npm install
58+
59+
npm run dev
60+
61+
npm run test
62+
```
63+
64+
## Release History
65+
66+
- 1.0.0
67+
- The first release
68+
69+
## Meta
70+
71+
Mater1996 – bxh8640@gmail.com
72+
73+
Distributed under the MIT license. See `LICENSE` for more information.
74+
75+
[LICENSE](https://github.com/Mater1996/omit/blob/master/LICENSE)
76+
77+
## Contributing
78+
79+
1. Fork it (<https://github.com/Mater1996/Mater1996.github.io>)
80+
2. Create your feature branch (`git checkout -b feature/fooBar`)
81+
3. Commit your changes (`git commit -am 'Add some fooBar'`)
82+
4. Push to the branch (`git push origin feature/fooBar`)
83+
5. Create a new Pull Request

docs/README_CN.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# EllipsisText
2+
3+
> A generator that gets the minimum content that corresponds to the height of an element
4+
5+
<!-- [![NPM Version][npm-image]][npm-url]
6+
[![Build Status][travis-image]][travis-url]
7+
[![Downloads Stats][npm-downloads]][npm-url] -->
8+
9+
![](header.png)
10+
11+
## Installation
12+
13+
npm:
14+
15+
```sh
16+
npm install omit --save-dev
17+
```
18+
19+
## Usage example
20+
21+
A few motivating and useful examples of how your product can be used. Spice this up with code blocks and potentially more screenshots.
22+
23+
```js
24+
import EllipsisText from 'ellipsis-text'
25+
new EllipsisText(dom, {
26+
str:
27+
'Fame,wealth and knowledge are merely worldly possessions that are withinthe reach of anybodyFame,wealth and knowledge are merely worldly possessions that are withinthe reach of anybodyFame',
28+
callback:function(res){
29+
console.log(res) // output:Fame,wealth and knowledge are merely worldly possessions that are withinthe reach of anybodyFame,wealth and knowled
30+
}
31+
})
32+
```
33+
34+
## EllipsisText API
35+
36+
```js
37+
38+
```
39+
40+
## Tips
41+
42+
EllipsisText used canvas to determine the number of lines to be intercepted
43+
44+
## Perfonmance
45+
46+
47+
48+
## Development setup
49+
50+
Describe how to install all development dependencies and how to run an automated test-suite of some kind. Potentially do this for multiple platforms.
51+
52+
```sh
53+
npm install
54+
55+
npm run dev
56+
57+
npm run test
58+
```
59+
60+
## Release History
61+
62+
- 1.0.0
63+
- The first release
64+
65+
## Meta
66+
67+
Mater1996 – bxh8640@gmail.com
68+
69+
Distributed under the MIT license. See `LICENSE` for more information.
70+
71+
[LICENSE](https://github.com/Mater1996/omit/blob/master/LICENSE)
72+
73+
## Contributing
74+
75+
1. Fork it (<https://github.com/Mater1996/Mater1996.github.io>)
76+
2. Create your feature branch (`git checkout -b feature/fooBar`)
77+
3. Commit your changes (`git commit -am 'Add some fooBar'`)
78+
4. Push to the branch (`git push origin feature/fooBar`)
79+
5. Create a new Pull Request

example/index.html

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="../dist/omit.umd.js"></script>
5+
<style>
6+
.main {
7+
width: 280px;
8+
overflow: hidden;
9+
word-break: break-all;
10+
}
11+
</style>
12+
</head>
13+
<body>
14+
<div class="main">
15+
16+
</div>
17+
<script>
18+
const main = document.querySelector('.main')
19+
const time1 = Date.now()
20+
let testStr = '<p>Fame,wealth and knowledge are merely worldly possessions that are withinthe reach of anybodyFame,wealth and knowledge are merely worldly possessions that are withinthe reach of anybodyFame</p>'
21+
var omit = new Omit(main,{
22+
str:new Array(1000).fill(testStr).join(''),
23+
callback:function(res){
24+
main.innerHTML = res;
25+
console.log(Date.now()-time1)
26+
}
27+
})
28+
console.log(omit)
29+
</script>
30+
</body>
31+
</html>

header.png

5 KB
Loading

0 commit comments

Comments
 (0)