
ellipsed.js is a very small(2kb) JavaScript library that truncates your long text to a specific number of lines.
Installation:
# Yarn $ yarn add ellipsed # NPM $ npm install ellipsed --save
How to use it:
Just include the ellipsed.js onto the webpage and you’re ready to go.
// ES Module
import { ellipsis } from 'ellipsed';
// CommonJS
var { ellipsis } = require('ellipsed');
// Browser
var ellipsis = window.ellipsed.ellipsis;Truncate the text to a specific number of lines you prefer.
// 2 lines
ellipsed('p', 2);
// 3 lines
ellipsed('p', 3);Available configurations which can be passed as the third parameter to the ellipsed method.
ellipsed('p', 3,{
// ellipsis character
replaceStr: '...',
// recall the function on window resize
responsive: false,
// debounce delay in miiliseconds
debounceDelay: 250,
// custom delimiter
delimiter: ' '
});Changelog:
v1.6.0 (11/24/2022)
- Updated dependencies
v1.5.0 (06/01/2020)
- Support node selector
v1.4.2 (10/14/2019)
- Fixed mobile scroll, triggered ellipsed only if screen-width changes
v1.4.1 (09/23/2019)
- Fix escaped tags when a text doesn’t need ellipsing
v1.4.0 (11/19/2018)
- feat: optional delimiter param
v1.3.1 (06/17/2018)
- fix for formatted content







