clamp.ts
Version:
TypeScript fork of clamp.js - Clamps an HTML element by adding ellipsis to it if the content inside is too long.
36 lines (35 loc) • 1.33 kB
TypeScript
/*!
* Clamp.js ported to TypeScript.
*
* Original author: Joseph Schmitt http://joe.sh under the WTFPL license
*
* Ported to TypeScript by Aamir Shah github.com/aamir1995
*/
/********************************************************
* *
* INTERFACES *
* *
*********************************************************/
export interface IClampOptions {
clamp?: number | string | 'auto';
useNativeClamp?: boolean;
splitOnChars?: Array<string>;
animate?: boolean;
truncationChar?: string;
truncationHTML?: string;
}
export interface IClampResponse {
original: string;
clamped: string;
}
/********************************************************
* *
* EXPORTED METHOD *
* *
*********************************************************/
/**
* @description Clamps a text node.
* @param element. Element containing the text node to clamp.
* @param options. Options to pass to the clamper.
*/
export declare function clamp(element: Element | HTMLElement, options?: IClampOptions): IClampResponse;