/** * Animate Images {@link https://github.com/its2easy/animate-images/} * @example * let pluginInstance = new AnimateImages(document.querySelector('canvas'), { * images: ['img1.jpg', 'img2.jpg', 'img3.jpg'], * loop: true, * draggable: true, * fps: 60, * }); */ declare class AnimateImages { /** * Creates plugin instance * @param {HTMLCanvasElement} node - canvas element * @param {PluginOptions} options */ constructor(node: HTMLCanvasElement, options: PluginOptions); /** * Start animation * @returns {AnimateImages} - plugin instance */ play(): AnimateImages; /** * Stop animation * @returns {AnimateImages} - plugin instance */ stop(): AnimateImages; /** * Toggle between start and stop * @returns {AnimateImages} - plugin instance */ toggle(): AnimateImages; /** * Show next frame * @returns {AnimateImages} - plugin instance */ next(): AnimateImages; /** * Show previous frame * @returns {AnimateImages} - plugin instance */ prev(): AnimateImages; /** * Show a frame with a specified number (without animation) * @param {number} frameNumber - Number of the frame to show * @returns {AnimateImages} - plugin instance */ setFrame(frameNumber: number): AnimateImages; /** * Start animation, that plays until the specified frame number * @param {number} frameNumber - Target frame number * @param {Object} [options] - Options * @param {boolean} [options.shortestPath=false] - If set to true and loop enabled, will use the shortest path * @returns {AnimateImages} - plugin instance */ playTo(frameNumber: number, options?: { shortestPath?: boolean; }): AnimateImages; /** * Start animation in the current direction with the specified number of frames in the queue * @param {number} [numberOfFrames=0] - Number of frames to play * @returns {AnimateImages} - plugin instance */ playFrames(numberOfFrames?: number): AnimateImages; /** * Change the direction of the animation. Alias to setOption('reverse', true) * @param {boolean} [reverse=true] - true for backward animation, false for forward, default "true" * @returns {AnimateImages} - plugin instance */ setReverse(reverse?: boolean): AnimateImages; /** * Get current reverse option. Alias to getOption('reverse') * @returns {boolean} - reverse or not */ getReverse(): boolean; /** * Change the direction of the animation. It does the opposite effect of setReverse() * @param {boolean} [forward=true] - true for forward animation, false for backward, default "true" * @returns {AnimateImages} - plugin instance */ setForward(forward?: boolean): AnimateImages; /** * Start preload specified number of images, can be called multiple times. * If all the images are already loaded, then nothing will happen * @param {number} number - Number of images to load. If not specified, all remaining images will be loaded. * @returns {AnimateImages} - plugin instance */ preloadImages(number?: number): AnimateImages; /** * Calculate new canvas dimensions. Should be called after the canvas size was changed manually * Called automatically after page resize * @returns {AnimateImages} - plugin instance */ updateCanvas(): AnimateImages; /** * Returns option value * @param {string} option - Option name. All options are allowed * @returns {*} - Current option value */ getOption(option: string): any; /** * Set new option value * @param {string} option - Option name. Allowed options: fps, loop, reverse, inversion, ratio, fillMode, draggable, dragModifier, * touchScrollMode, pageScrollTimerDelay, onPreloadFinished, onPosterLoaded, onAnimationEnd, onBeforeFrame, onAfterFrame * @param {*} value - New value * @returns {AnimateImages} - plugin instance */ setOption(option: string, value: any): AnimateImages; /** @returns {number} - current frame number */ getCurrentFrame(): number; /** @returns {number} - total frames (considering loading errors) */ getTotalImages(): number; /** @returns {number} - current canvas ratio */ getRatio(): number; /** @returns {boolean} - animating or not */ isAnimating(): boolean; /** @returns {boolean} - returns true if a drag action is in progress */ isDragging(): boolean; /** @returns {boolean} - is preload finished */ isPreloadFinished(): boolean; /** @returns {boolean} - is fast preview mode preload finished */ isFastPreloadFinished(): boolean; /** @returns {boolean} - is loaded with errors */ isLoadedWithErrors(): boolean; /** * Stop the animation and return to the first frame * @returns {AnimateImages} - plugin instance */ reset(): AnimateImages; /** * Stop animation, remove event listeners and clear the canvas. Method doesn't remove canvas element from the DOM */ destroy(): void; #private; } type PluginOptions = { /** * - Array with images URLs (required) */ images?: Array; /** * - Preload mode ("all", "none", "partial") */ preload?: 'all' | 'partial' | 'none'; /** * - Number of preloaded images when preload: "partial", 0 for all */ preloadNumber?: number; /** * - Url of a poster image, to show before load */ poster?: string; /** * - FPS when playing. Determines the duration of the animation (for example 90 images and 60 * fps = 1.5s, 90 images and 30fps = 3s) */ fps?: number; /** * - Loop the animation */ loop?: boolean; /** * - Autoplay */ autoplay?: boolean; /** * - Reverse direction * reverse means forward or backward, and inversion determines which direction is forward. Affects animation and drag */ reverse?: boolean; /** * - Canvas width/height ratio, it has higher priority than inline canvas width and height */ ratio?: number; /** * - Fill mode to use if canvas and image aspect ratios are different * ("cover" or "contain") */ fillMode?: 'cover' | 'contain'; /** * - Draggable by mouse or touch */ draggable?: boolean; /** * - Inversion changes drag direction */ inversion?: boolean; /** * - Sensitivity factor for user interaction. Only positive numbers are allowed */ dragModifier?: number; /** * - Page * scroll behavior with touch events (preventPageScroll,allowPageScroll, pageScrollTimer) */ touchScrollMode?: 'pageScrollTimer' | 'preventPageScroll' | 'allowPageScroll'; /** * - Time in ms when touch scroll will be disabled during interaction * if touchScrollMode: "pageScrollTimer" */ pageScrollTimerDelay?: number; /** * - Which side will be responsive (controlled by css) */ responsiveAspect?: 'width' | 'height'; /** * - Special mode for interactivity after loading only a part of the pictures */ fastPreview?: any | false; /** * - fps value that will be applied after the full list of images is loaded */ fpsAfter?: number; /** * - A function that takes the frame number of the short set * and returns the frame number of the full set, to prevent jump after full load. */ matchFrame?: (arg0: number) => number; /** * - Occurs when all image files have been loaded */ onPreloadFinished?: (arg0: AnimateImages) => void; /** * - Occurs when all fastPreview mode images have been loaded */ onFastPreloadFinished?: (arg0: AnimateImages) => void; /** * - Occurs when poster image is fully loaded */ onPosterLoaded?: (arg0: AnimateImages) => void; /** * - Occurs when animation has ended */ onAnimationEnd?: (arg0: AnimateImages) => void; /** * - Occurs before new frame */ onBeforeFrame?: (arg0: AnimateImages, arg1: FrameInfo) => void; /** * - Occurs after the frame was drawn */ onAfterFrame?: (arg0: AnimateImages, arg1: FrameInfo) => void; }; type FrameInfo = { /** * - canvas context */ context: CanvasRenderingContext2D; /** * - internal canvas width */ width: number; /** * - internal canvas height */ height: number; }; export { AnimateImages as default };