UNPKG

@jirkasa/code-box

Version:

Showcase code samples on the web with a container that lets users select and display different samples.

62 lines (61 loc) 2.34 kB
/** Represents collapsible. */ declare class Collapsible { /** Small delay that is used to trigger CSS animations. */ private static readonly DELAY_TIMEOUT; /** Button element. */ private buttonElement; /** Collapsible element. */ private collapsibleElement; /** Open/close animation speed in miliseconds. */ private animationSpeed; /** CSS easing function for open/close animation. */ private animationEasingFunction; /** Function that is called when collapsible is opened/closed. */ private onToggle; /** Indicates whether collapsible is currently opened. */ private opened; /** Indicates whether collapsible is currently being animated. */ private isAnimating; /** Timeout id of animation timeout function. */ private animationTimeoutId; /** Tiemout id of delay timeout function, that is used to trigger animations. */ private delayTimeoutId; /** * Creates new collapsible. * @param buttonElement Button element. * @param collapsibleElement Collapsible element. * @param animationSpeed Open/close animation speed in miliseconds. * @param animationEasingFunction CSS easing function for open/close animation. * @param onToggle Function to be called when collapsible is opened/closed. */ constructor(buttonElement: HTMLButtonElement, collapsibleElement: HTMLElement, animationSpeed: number, animationEasingFunction: string, onToggle: () => void); /** * Opens collapsible. * @param animate Determines whether animation should be used. */ open(animate?: boolean): void; /** * Closes collapsible. * @param animate Determines whether animation should be used. */ close(animate?: boolean): void; /** * Checks whether collapsible is opened. * @returns Indicates whether collapsible is opened. */ isOpened(): boolean; /** * Called when button is clicked. */ private onButtonClick; /** * Clears timeout functions. */ private clearTimeouts; /** * Returns height of collapsible element. (After calling this method, "max-height" property is removed and must be reassigned if necessary.) * @returns Height of collapsible element. */ private getCollapsibleElementHeight; } export default Collapsible;