All Projects → nzambello → Ellipsed

nzambello / Ellipsed

Licence: mit
A JavaScript library for multilined ellipsis

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ellipsed

Easygrid
EasyGrid - VanillaJS Responsive Grid
Stars: ✭ 77 (-70.5%)
Mutual labels:  frontend, javascript-library
Angular Tree Component
A simple yet powerful tree component for Angular (>=2)
Stars: ✭ 1,031 (+295.02%)
Mutual labels:  frontend, javascript-library
jquery.skeleton.loader
A jQuery plugin to make screen skeleton loader.
Stars: ✭ 65 (-75.1%)
Mutual labels:  javascript-library
tiny-lit
JavaScript library for building user interfaces using template literals
Stars: ✭ 17 (-93.49%)
Mutual labels:  javascript-library
lexicon-mono-seq
DOM Text Based Multiple Sequence Alignment Library
Stars: ✭ 15 (-94.25%)
Mutual labels:  javascript-library
ring-election
A node js library with a distributed leader/follower algorithm ready to be used
Stars: ✭ 92 (-64.75%)
Mutual labels:  javascript-library
afinn
Sentiment Analysis in Javascript using the AFINN Lexicon
Stars: ✭ 26 (-90.04%)
Mutual labels:  javascript-library
aioneframework
Aione Framework: All-in-one lightweight mobile first front-end framework to design websites, web applications, mobile applications, progressive web applications having large number of examples, documentation, tutorials, community support, components.
Stars: ✭ 13 (-95.02%)
Mutual labels:  javascript-library
Qmlcore
QML to Javascript/HTML5 translator, both for mobile and desktop targets
Stars: ✭ 258 (-1.15%)
Mutual labels:  frontend
previewSlider
Responsive fullscreen image slider where the users are able to preview next/previous image when hovering over the navigation arrows.
Stars: ✭ 16 (-93.87%)
Mutual labels:  javascript-library
typical
Isomorphic, functional type-checking for Javascript
Stars: ✭ 17 (-93.49%)
Mutual labels:  javascript-library
spacers
🔳 when you need more __space__ for your no-code tools.
Stars: ✭ 211 (-19.16%)
Mutual labels:  javascript-library
excel-date-to-js
Convert Excel date in integer format into JS date. Dates are stored as numbers in Excel and count the number of days since January 0, 1900 (1900 standard, for mac it is 1904, which means January 0, 1904 is the start date). Times are handled internally as numbers between 0 and 1.
Stars: ✭ 26 (-90.04%)
Mutual labels:  javascript-library
diaeresis
A lightweight (<1kb minified + gzipped) JavaScript library that lets you wield diæreses like C̶h̶u̶c̶k̶ Mary Norris:
Stars: ✭ 15 (-94.25%)
Mutual labels:  javascript-library
cerbero
Track your users interactions
Stars: ✭ 56 (-78.54%)
Mutual labels:  javascript-library
Tui
This is a high quanlity components library for VUE
Stars: ✭ 258 (-1.15%)
Mutual labels:  javascript-library
validate
An extension to the popular library validate.js that adds some useful custom validations out of the box. Also, a hub for all custom validations, that we have created, so you can easily add them to your own project.
Stars: ✭ 31 (-88.12%)
Mutual labels:  javascript-library
xss-firewall
xss monitor and intercept
Stars: ✭ 16 (-93.87%)
Mutual labels:  javascript-library
validate-polish
Utility library for validation of PESEL, NIP, REGON, identity card etc. Aimed mostly at Polish enviroment. [Polish] Walidacja numerów pesel, nip, regon, dowodu osobistego.
Stars: ✭ 31 (-88.12%)
Mutual labels:  javascript-library
Jschema
A simple, easy to use data modeling framework for JavaScript
Stars: ✭ 261 (+0%)
Mutual labels:  javascript-library

Ellipsed

license   GitHub forks GitHub stars
npm version npm compatibility

contributions welcome Join the chat at https://gitter.im/ellipsed/Lobby   Demo

What is Ellipsed?

Ellipsed is a JavaScript library for generating multi-lined ellipsed text.
Indicating the number of visible lines, it will truncate the text at the correct position in targeted elements.

Example screenshot

Demo

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 yarn start).

Install

# Yarn
yarn add ellipsed

# NPM
npm install --save ellipsed

# Bower
bower install ellipsed

Usage

Call the ellipsis method with three parameters:

ellipsis(selector, rows, options);
  • selector - A CSS selector string or the DOM Node or Node List 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 replaceStr (default is '...').
  • options - Allows an options object to be passed to further customise the functionality. See options section below for details.

If 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

Options can be passed through the method using the third parameter, which provides greater control.

Name Type Default Description
replaceStr string '...' The string that substituted following the trucated string.
responsive boolean false If true, the method is re-called on resize event, so the number of rows is preserved.
debounceDelay integer 250 If responsive option is set, it's the delay value for resizing events debouncing.
delimiter string ' ' Use '' for text written in languages such as Japanese, Chinese, etc. since there's usually no space break in such languages; or for text contains long word (word that is longer than the width of the container).

Import

Ellipsed is provided as a UMD module.

You can use it as a ES6 module:

import { ellipsis } from 'ellipsed';

As a CommonJS module:

var { ellipsis } = require('ellipsed');

As an AMD module:

require([
  'ellipsed'
], function(ellipsed) {
  var ellipsis = ellipsed.ellipsis;
});

Or as a global module in the browser:

var ellipsis = window.ellipsed.ellipsis;

Performance

It seems that having multiple calls of ellipsis with responsive option enabled would add multiple event listeners and would be recommended to use a single call with a multiple selector. A single event listener should be more efficient and events handling more fluid.

Browser support

The library has been tested on:

  • Google Chrome 60+
  • Firefox 55+
  • Safari 10+
  • Edge 14+
  • IE 9+

Contributing

New contributors are warmly welcome, see the CONTRIBUTING.md file for other information.

Many thanks to @nekorina for project's logo.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].