All Projects → glinford → Ellipsis.js

glinford / Ellipsis.js

Licence: mit
Ellipsis.js - Pure Javascript Library to handle complex multilines ellipsis

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ellipsis.js

Password Leak
A library to check for compromised passwords
Stars: ✭ 92 (-24.59%)
Mutual labels:  javascript-library
Selection
✨ Selection - A simple and lightweight library to add a visual way of selecting elements, just like on your Desktop. Zero dependencies. Full mobile and scroll support.
Stars: ✭ 1,371 (+1023.77%)
Mutual labels:  javascript-library
Smart Webcomponents
Web Components & Custom Elements for Professional Web Applications
Stars: ✭ 110 (-9.84%)
Mutual labels:  javascript-library
Gdrivesync.js
Javascript wrapper library for Google Drive API v3
Stars: ✭ 94 (-22.95%)
Mutual labels:  javascript-library
Mobilebone
Single Page Switching bone(include page manage, events manage) for mobile web APP, Hybrid APP, Phonegap, PPT, Single-Screen PC page...
Stars: ✭ 1,357 (+1012.3%)
Mutual labels:  javascript-library
Stanchion
Add priorities to your web app's network requests
Stars: ✭ 103 (-15.57%)
Mutual labels:  javascript-library
Ssim
🖼🔬 JavaScript Image Comparison
Stars: ✭ 83 (-31.97%)
Mutual labels:  javascript-library
Dom7
Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
Stars: ✭ 119 (-2.46%)
Mutual labels:  javascript-library
Nodeppt
This is probably the best web presentation tool so far!
Stars: ✭ 9,589 (+7759.84%)
Mutual labels:  javascript-library
Musjs
🐁 Mouse tracking javascript library - Follow me on Twitter @mauriciogior
Stars: ✭ 109 (-10.66%)
Mutual labels:  javascript-library
Date Picker
Duet Date Picker is an open source version of Duet Design System’s accessible date picker. Try live example at https://duetds.github.io/date-picker/
Stars: ✭ 1,325 (+986.07%)
Mutual labels:  javascript-library
Capivarajs
✌️ Um novo jeito de criar componentes híbridos.
Stars: ✭ 97 (-20.49%)
Mutual labels:  javascript-library
Reimg
reimg - A javascript library for converting image formats
Stars: ✭ 106 (-13.11%)
Mutual labels:  javascript-library
Accordion
Accordion module created in pure javascript & CSS. Very useful to create FAQ lists on your website.
Stars: ✭ 94 (-22.95%)
Mutual labels:  javascript-library
Mobiscroll
Cross platform UI controls for progressive web and hybrid apps (plain JS, jQuery, Angular and React)
Stars: ✭ 1,510 (+1137.7%)
Mutual labels:  javascript-library
Zifi
zifi - Make Stories everywhere using React 😍
Stars: ✭ 87 (-28.69%)
Mutual labels:  javascript-library
Consolemock
A tool for testing console logs
Stars: ✭ 103 (-15.57%)
Mutual labels:  javascript-library
React Rainbow
🌈 React Rainbow Components. Build your web application in a snap.
Stars: ✭ 1,662 (+1262.3%)
Mutual labels:  javascript-library
Javascript Avanzado En Espanol
Esta es una traducción de la serie de libros de You Don't Know JS (book series), la cual es una serie de 6 libros que navegan profundamente en los mecanismos básicos y avanzados del lenguaje JavaScript. La primera edición de la serie está ahora completa.
Stars: ✭ 118 (-3.28%)
Mutual labels:  javascript-library
Anime
JavaScript animation engine
Stars: ✭ 41,064 (+33559.02%)
Mutual labels:  javascript-library

Ellipsis.js

Ellipsis.js is a Pure Javascript Library to add some ellipsis on some complex DOM elements such as multiline divs or elements with childs (links, spans, etc.). The library is fully responsive, works across all major browsers, and try to be highly configurable. It is also very light, with a size of ~4kb when minified.


Demo:

https://glinford.github.io/ellipsis.js/


Installation:

Bower

bower install ellipsis.js

NPM

npm install ellipsis.js

Or…

git clone https://github.com/glinford/ellipsis.js

Usage:

<script src="/your/path/ellipsis.min.js"></script>
<script type="text/javascript">
  Ellipsis(); //default conf
</script>

By default Ellipsis.js will work on DOM elements that have a 'clamp' class and will add ellipsis after 2 lines.


Configuration properties:

{
  ellipsis: '…', //default ellipsis value
  debounce: 0, //if you want to chill out your memory usage on resizing
  responsive: true, //if you want the ellipsis to move with the window resizing
  className: '.clamp', //default class to apply the ellipsis
  lines: 2 //default number of lines when the ellipsis will appear
  portrait: null //default no change, put a number of lines if you want a different number of lines in portrait mode,
  break_word: true //default the ellipsis can truncate words
}

Lists:

  • debounce | Number | Default: 0 | Value in Milliseconds. If set to 0, it will use window.requestAnimationFrame (or a polyfill for IE <= 9) to debounce the resize events.
  • responsive | Boolean | Default: true | True is you want the ellipsis to be responsive, false if not.
  • className | String | Default: '.clamp' | A class or valid query selector where you want your ellipsis to appear
  • lines | Number | Default: 2 | The maximum number of lines before ellipsis
  • portrait | Number | Default: null | If you want a different number from the lines property on portrait mode.
  • break_word | Boolean | Default: true | If true the words can be truncated by the ellipsis, eg: "Hello Wo…", if false they won't, eg "Hello …"

"Manual" mode:

You can use the Ellipsis.js object to apply the configuration to additional DOM elements after it has been loaded:

var ellipsis = Ellipsis();
var elements = document.getElementsByClassName('.special-title');
ellipsis.add(elements);

This can be done with a single element:

ellipsis.add(elements[0]);

If using Ellipsis.js manually, you can disable the selector option in the configuration like this:

var ellipsisConf = {className: false};
var ellipsis = Ellipsis(ellipsisConf);

Known Issues:

By default the line-height property of a text is 'normal' which cannot be computed with getComputedStyle() method. If that occurs we will replace the line-height from normal to font-size + 2px which is the default value for most of browsers/OS.

The library does some heavy computation so it wont be suitable for pages that have like 100 elements with 100 lines each. I will work on optimization in future releases.

SVG text not supported.


To Do / Contributions:

  • Speed Improvement
  • SVG text support
  • Gradient instead of "String" Ellipsis

Feel free to branch and PR :)


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].