clamp-js definition files added (#13527)

This commit is contained in:
Sebastiaan de Rooij
2017-01-17 20:08:23 -08:00
committed by Mohamed Hegazy
parent 58bf82b737
commit 1bfcf017f4
4 changed files with 74 additions and 0 deletions
+28
View File
@@ -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>'
});
Vendored Executable
+25
View File
@@ -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;
+20
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }