Truncating Overflowing Text By Lines – ellipsed.js

Category: Javascript , Text | November 19, 2018
Author: nzambello
Views Total: 1,516
Official Page: Go to website
Last Update: November 19, 2018
License: MIT

Preview:

Truncating Overflowing Text By Lines – ellipsed.js

Description:

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.

<script src="ellipsed.js"></script>

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.4.0 (11/19/2018)

  • feat: optional delimiter param

v1.3.1 (06/17/2018)

  • fix for formatted content

You Might Be Interested In:


Leave a Reply