typeinit
Version:
An Intuitive Javascript Typing Animation Library
70 lines (69 loc) • 2.24 kB
TypeScript
import { DeleteAllOptionsInterface, DeleteOptionsInterface, OptionsInterface, TypeinitInterface, WriterType } from "./types";
/**
* Welcome to Typeinit! 😍
* @param {(Object|string)} selector HTML element OR HTML element selector
* @param {Object} [optionsObj] options Object
* @returns {Object} a new Typeinit Object
*/
export default class Typeinit implements TypeinitInterface {
#private;
constructor(selector: HTMLElement | string, optionsObj?: OptionsInterface);
/**
* Adds the styles for the caret
* @private
*/
private _addStyles;
/**
* Types out each character
* @param {string} message the string to type
* @returns {Object} a typeinit Object
* @public
*/
type(message: string): WriterType;
/**
* Deletes 1 character at a time or 1 word at a time
* @param {number} [numToDel] the number of characters or words to be deleted
* @param {Object} [deleteOptions] sets the mode, delay and speed of the deletion
* @returns {Object} a typeinit Object
* @public
*/
delete(numToDel?: number, deleteOptions?: DeleteOptionsInterface): this;
/**
* Deletes all the characters in the element
* @param {boolean} [ease] how the deletion should happen
* @param {Object} [deleteAllOptions] sets the speed and delay of the deletion
* @returns {Object} a typeinit Object
* @public
*/
deleteAll(ease?: boolean, deleteAllOptions?: DeleteAllOptionsInterface): this;
/**
* Adds a new line to the element
* @param {number} [numOfLines=1] the number of new lines to add
* @returns {Object} a typeinit Object
* @public
*/
newLine(numOfLines?: number): this;
/**
* Pauses the animation
* @param {number} [ms=options.pause] the amount of time in milliseconds to pause
* @returns {Object} a typeinit Object
* @public
*/
pause(ms?: number): this;
/**
* Resets the Target element and destroys the Typeinit instance.
* @public
*
*/
reset(): void;
/**
* Restarts the typing animation
* @public
*/
restart(): void;
/**
* Begins the typing animation
* @public
*/
play(): void;
}