mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 11:57:33 +08:00
29 lines
875 B
TypeScript
29 lines
875 B
TypeScript
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>'
|
||
});
|