Gathering detailed insights and metrics for clamp-js-main-silent
Gathering detailed insights and metrics for clamp-js-main-silent
npm install clamp-js-main-silent
Typescript
Module System
Node Version
NPM Version
70.9
Supply Chain
90.5
Quality
74.9
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
1,617
Last Day
2
Last Week
3
Last Month
14
Last Year
81
60 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Jun 07, 2017
Minified
Minified + Gzipped
Latest Version
0.11.3
Package Id
clamp-js-main-silent@0.11.3
Size
5.54 kB
NPM Version
5.0.3
Node Version
8.0.0
Cumulative downloads
Total Downloads
Last Day
100%
2
Compared to previous day
Last Week
200%
3
Compared to previous week
Last Month
100%
14
Compared to previous month
Last Year
-30.8%
81
Compared to previous year
No dependencies detected.
Clamps (ie. cuts off) an HTML element's content by adding ellipsis to it if the content inside is too long.
npm install clamp-js-main
git clone git@github.com:jmenglis/clamp-js-main.git
and moving the script.js to your project. Then include it in your index.html.//Single line $clamp(myHeader, {clamp: 1}); //Multi-line $clamp(myHeader, {clamp: 3}); //Auto-clamp based on available height $clamp(myParagraph, {clamp: 'auto'}); //Auto-clamp based on a fixed element height $clamp(myParagraph, {clamp: '35px'});
The $clamp method is the primary way of interacting with Clamp.js, and it takes two arguments. The first is the element which should be clamped, and the second is an Object with options in JSON notation.
clamp (Number | String | 'auto'). This controls where and when to clamp the text of an element. Submitting a number controls the number of lines that should be displayed. Second, you can submit a CSS value (in px or em) that controls the height of the element as a String. Finally, you can submit the word 'auto' as a string. Auto will try to fill up the available space with the content and then automatically clamp once content no longer fits. This last option should only be set if a static height is being set on the element elsewhere (such as through CSS) otherwise no clamping will be done.
useNativeClamp (Boolean). Enables or disables using the native -webkit-line-clamp in a supported browser (ie. Webkit). It defaults to true if you're using Webkit, but it can behave wonky sometimes so you can set it to false to use the JavaScript- based solution.
truncationChar (String). The character to insert at the end of the HTML element after truncation is performed. This defaults to an ellipsis (…).
truncationHTML (String). A string of HTML to insert before the truncation character. This is useful if you'd like to add a "Read more" link or some such thing at the end of your clamped node.
splitOnChars (Array). Determines what characters to use to chunk an element into smaller pieces. Version 0.1 of Clamp.js would always remove each individual character to check for fit. With v0.2, you now have an option to pass a list of characters it can use. For example, it you pass an array of ['.', ',', ' '] then it will first remove sentences, then remove comma-phrases, and remove words, and finally remove individual characters to try and find the correct height. This will lead to increased performance and less looping when removing larger pieces of text (such as in paragraphs). The default is set to remove sentences (periods), hypens, en-dashes, em-dashes, and finally words (spaces). Removing by character is always enabled as the last attempt no matter what is submitted in the array.
animate (Boolean). Silly little easter-egg that, when set to true, will animate removing individual characters from the end of the element until the content fits. Defaults to false.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More