Files
DefinitelyTyped/types/clamp-js/clamp-js-tests.ts
2017-03-24 14:27:52 -07:00

29 lines
875 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>'
});