Package Exports
- truncated.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (truncated.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Truncated.js
Truncated.js is a javascript plugin that shortens a text string based on a specified max-height & adds an ellipsis at the end.
Setup
npm install truncated.js --save-devbower install truncated.js --save-devRun
- Include truncated.js into your
vendorfile or in a<script>tag. - Add truncated
css/scssto yourcss. truncatethe element you'd like to give truncation to.
truncated('selector', maxHeight);🔥Basic Examples
Basic
truncated('selector', maxHeight);Or Multiples
truncated('selector', maxHeight);But not this one
truncated('selector:not([not this selector])', maxHeight);How?
Truncated.js trims a text string to a last full word of what can fit within a specified max height.
Why?
Truncated.js is made simpicity when it comes to text truncation. Several plugins that I've looked at oversolve what people want when they want text truncation - for text to look nice in a specified space. Here's a basic example & with jQuery.
This plugin is small - ~1kb unminified & is meant to do 1 thing - truncate text based on a specified max height.
Options
If you'd like to not use the classname 'js-truncated', just use your own.
reframe('selector', 'classname');jQuery
You can use truncated with jQuery.
$('selector').reframe(maxheight);&, if you'd like to use a custom classname instead of 'js-truncated'
$('selector').reframe(maxheight, 'classname');