With NSS-Ellipsis you can add ellipsis to multiline text
NSS-Ellipsis can be installed with npm or simply using a content delivery network (CDN) URL to embed NSS-Ellipsis directly on your HTML page.
npm install nss-ellipsis
The correct way to import NSS-Ellipsis is:
import NSSEllipsis from 'nss-ellipsis'
NSSEllipsis.update(element, 3)
// to set precision to letter
NSSEllipsis.update(element, 3, NSSEllipsis.LETTER_PRECISION)
Using common file:
<script async src="../dist/nss-ellipsis.common.js"></script>
https://github.com/jerome-birembaut/nss-ellipsis/releases/tag/0.0.10
- ellipsis a dom element (yeah)
- lineMax
- precision to word or letter
const element = document.getElementById(id)
const lineMax = 3
NSSEllipsis.update(element, lineMax)
// it's Responsive Baby!!!
const lineMax = 2;
const onResize = function() {
[...document.querySelectorAll(".to-ellipsis")].map(element => {
NSSEllipsis.update(element, 3)
})
}
window.addEventListener('resize', onResize)
onResize()
npm install
npm run build
This content is released under the (http://opensource.org/licenses/MIT) MIT License.