Indicating the number of visible lines, it will truncate the text at the correct position in targeted elements.
You can see the demo here: https://nzambello.github.io/ellipsed/
The example/ directory of this repo contains the demo showed above.
To start it on your local machine, clone the repository and install it by following the installation instructions below, then start it with
npm start (or with
# Yarnyarn add ellipsed# NPMnpm install --save ellipsed# Bowerbower install ellipsed
Call the ellipsis method with three parameters:
selector- A CSS selector string used to target the element for truncation
rows- An integer value used as the number of rows that should be visible, following words will be trucated with the
options- Allows an options object to be passed to further customise the functionality. See options section below for details.
responsive option is set, the function returns the ID of the listener returned by
setTimeout. It can be useful to clear resize handler timeout.
Options can be passed through the method using the third parameter, which provides greater control.
||The string that substituted following the trucated string.|
||If true, the method is re-called on resize event, so the number of rows is preserved.|
Ellipsed is provided as a UMD module.
You can use it as a ES6 module:
As a CommonJS module:
var ellipsis = ;
As an AMD module:
Or as a global module in the browser:
var ellipsis = windowellipsedellipsis;
The library has been tested on:
New contributors are warmly welcome, see the CONTRIBUTING.md file for other information.
Many thanks to @nekorina for project's logo.