canvas-scroll-clip
Version:
Canvas based image sequence scroll animation. Zero dependencies.
106 lines (105 loc) • 2.55 kB
TypeScript
import { ICanvasViewport, IFrame, IFrameSequence } from "./intefaces";
/**
* RegExp expression to find last digits in a string
*/
export declare const RegExpLastDigitsMatch: RegExp;
/**
* Available events
**/
export declare const AppEvent: {
viewport: {
resize: string;
scroll: string;
};
images: {
progress: string;
loaded: string;
};
};
/**
* List of events
**/
export declare const EventList: unknown[];
/**
* Debounce ot throttle function
*
* @param {func}
* @param {threshold}
* @returns
*/
export declare const debounce: <F extends (...args: any) => any>(func: F, threshold?: number) => any;
/**
* Preload images
*
* @param {imagesList} Array of strings
* @param {callback} CallbackFunction
*/
export declare function getImage(imageLink: string): Promise<HTMLImageElement>;
/**
* Preloading image list
*
* @returns Promise<HTMLImageElement>[]
*/
export declare function preloadImages(frameOptions: IFrame): Promise<HTMLImageElement>[];
/**
* Get scroll top position
*
* @returns number
*/
export declare function getScrollTop(): number;
/**
* Get scroll top position
*
* @param {scrollTop}
* @param {ICanvasViewport}
* @returns number
*/
export declare function getScrollFraction(cViewport: ICanvasViewport, scrollTop?: number): number;
/**
* Get frame URL by frame number
*
* @param {IFrame} frameOptions
* @param {number} frameNumber
* @returns {string}
*/
export declare function getFramePathByIndex(frameOptions: IFrame, frameNumber?: number): string;
/**
* Get image base path
*
* @param firstFramePath
* @returns
*/
export declare function getImageBasePath(firstFramePath: string): string;
/**
* Get frame image structure
*
* @param {string} firstFramePath
* @param {number} frameCount
* @returns
* @throws {AppError}
*/
export declare function getImageStructure(firstFramePath: string, frameCount: number): IFrameSequence;
/**
* Get image sequence with leading zeros
*
* @param {string} imageName
* @returns {string}
* @throws {AppError} image sequence format not supported
*/
export declare function getImageSequence(imageName: string): string;
/**
* Get file extension/suffix
* Test whether is within supported extension/suffixes list
*
* @param fileName
* @returns {string}
* @throws {AppError} Unsupported image
*/
export declare function getFileSuffix(fileName: string): string;
/**
* Get ending of a url
*
* @param path
* @returns
*/
export declare function getPathEnding(path: string): string;