Comparing version 0.0.6 to 0.0.7
25
index.js
@@ -7,17 +7,2 @@ function truncateTextNode ( | ||
) { | ||
truncateTextNodeByWord( | ||
textNode, | ||
rootElement, | ||
maximumHeight, | ||
ellipsisCharacter | ||
) | ||
return truncateTextNodeByCharacter( | ||
textNode, | ||
rootElement, | ||
maximumHeight, | ||
ellipsisCharacter | ||
) | ||
} | ||
function truncateTextNodeByWord (textNode, rootElement, maximumHeight) { | ||
var lastIndexOfWhitespace | ||
@@ -28,3 +13,3 @@ var textContent = textNode.textContent | ||
if (lastIndexOfWhitespace == -1) { | ||
return | ||
break | ||
} | ||
@@ -34,6 +19,12 @@ textNode.textContent = textContent.substring(0, lastIndexOfWhitespace) | ||
textNode.textContent = textContent | ||
return | ||
break | ||
} | ||
textContent = textNode.textContent | ||
} | ||
return truncateTextNodeByCharacter( | ||
textNode, | ||
rootElement, | ||
maximumHeight, | ||
ellipsisCharacter | ||
) | ||
} | ||
@@ -40,0 +31,0 @@ |
{ | ||
"name": "line-clamp", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Line clamp a DOM element in vanilla JavaScript.", | ||
@@ -22,3 +22,3 @@ "author": "Lim Yuan Qing", | ||
"start": "concurrently \"watchify index.js --standalone lineClamp --outfile example/bundle.js\" \"ecstatic example --port 8080\" \"opn 'http://0.0.0.0:8080/'\"", | ||
"lint": "prettier-standard index.js test/index.js --no-semi --single-quote --write", | ||
"lint": "prettier-standard index.js --no-semi --single-quote --write", | ||
"weight": "uglifyjs index.js --compress --mangle --toplevel | gzip-size" | ||
@@ -25,0 +25,0 @@ }, |
@@ -5,7 +5,6 @@ # line-clamp [![npm Version](http://img.shields.io/npm/v/line-clamp.svg?style=flat)](https://www.npmjs.com/package/line-clamp) [![Build Status](https://img.shields.io/travis/yuanqing/line-clamp.svg?branch=master&style=flat)](https://travis-ci.org/yuanqing/line-clamp) | ||
- Pure JavaScript; does *not* use [`-webkit-line-clamp`](https://css-tricks.com/line-clampin/) | ||
- Truncates in pure JavaScript; does *not* rely on [`-webkit-line-clamp`](https://css-tricks.com/line-clampin/) | ||
- Works even if the given element contains nested DOM nodes | ||
- Supports appending a custom string instead of an ellipsis | ||
- Exit if we detect that content does not actually overflow the element | ||
- 494 bytes gzipped | ||
- Supports appending a custom string instead of an ellipsis (`…`) | ||
- 476 bytes gzipped | ||
@@ -84,2 +83,3 @@ ## Usage | ||
- [FTEllipsis](https://github.com/ftlabs/ftellipsis) | ||
- [Shave](https://github.com/dollarshaveclub/shave) | ||
@@ -86,0 +86,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113544
100