mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
clamp-js definition files added (#13527)
This commit is contained in:
committed by
Mohamed Hegazy
parent
58bf82b737
commit
1bfcf017f4
Executable
+28
@@ -0,0 +1,28 @@
|
||||
import * as clamp from 'clamp-js';
|
||||
|
||||
const lineElement: HTMLElement = document.createElement('div');
|
||||
lineElement.style.setProperty('font-size', '3px');
|
||||
lineElement.style.setProperty('line-height', '5px');
|
||||
lineElement.style.setProperty('height', '11px');
|
||||
lineElement.style.setProperty('width', '15px');
|
||||
|
||||
const newtext: Text = document.createTextNode('Lorem ipsum, dolor sit amet.');
|
||||
lineElement.appendChild(newtext);
|
||||
|
||||
const clampFromElement = clamp(lineElement);
|
||||
const clampFromDefaults = clamp(lineElement, {
|
||||
clamp: 'auto',
|
||||
useNativeClamp: true,
|
||||
splitOnChars: ['.', '-', '–', '—', ' '],
|
||||
animate: false,
|
||||
truncationChar: '…',
|
||||
truncationHTML: null
|
||||
});
|
||||
const clampWithOptions = clamp(lineElement, {
|
||||
clamp: 1,
|
||||
useNativeClamp: false,
|
||||
splitOnChars: [','],
|
||||
animate: true,
|
||||
truncationChar: '--',
|
||||
truncationHTML: '<span></span>'
|
||||
});
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// Type definitions for clamp-js 0.7
|
||||
// Project: https://github.com/xavi160/Clamp.js
|
||||
// Definitions by: Sebastiaan de Rooij <https://github.com/Hikariii/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace clamp {
|
||||
export interface ClampOptions {
|
||||
clamp?: number|string;
|
||||
useNativeClamp?: boolean;
|
||||
splitOnChars?: string[];
|
||||
animate?: boolean;
|
||||
truncationChar?: string;
|
||||
truncationHTML?: string | null;
|
||||
}
|
||||
|
||||
export interface ClampResponse {
|
||||
'original': string;
|
||||
'clamped': string;
|
||||
}
|
||||
}
|
||||
|
||||
declare function clamp(element: HTMLElement, options?: clamp.ClampOptions): clamp.ClampResponse;
|
||||
|
||||
export = clamp;
|
||||
export as namespace clamp;
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"clamp-js-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user