kinetic-slider
Version:
A WebGL-powered kinetic slider component using PIXI.js
77 lines (76 loc) • 2.71 kB
TypeScript
import { Sprite, Texture, Container, type Renderer } from 'pixi.js';
import { type EnhancedSprite } from '../types';
import ResourceManager from '../managers/ResourceManager';
/**
* Options for creating a placeholder sprite
*/
export interface PlaceholderOptions {
/** Width of the placeholder */
width: number;
/** Height of the placeholder */
height: number;
/** Background color (hex) */
color?: number;
/** Whether to add a label with the slide index */
showIndex?: boolean;
/** Slide index (for labeling) */
index?: number;
/** Whether to track with resource manager */
trackWithResourceManager?: boolean;
/** Resource manager instance */
resourceManager?: ResourceManager | null;
/** Renderer instance for texture generation */
renderer?: Renderer;
}
/**
* Container with loading animation capabilities
*/
export interface LoadingContainer extends Container {
updateLoading: (delta: number) => void;
}
/**
* Sprite with rotation animation flag
*/
export interface LoadingSprite extends Sprite {
_rotate: boolean;
}
/**
* Create a lightweight placeholder sprite for slides outside the visibility window
*
* @param options - Placeholder options
* @returns Enhanced sprite with placeholder graphics
*/
export declare function createPlaceholderSprite(options: PlaceholderOptions): EnhancedSprite;
/**
* Check if a sprite is a placeholder
*
* @param sprite - Sprite to check
* @returns Whether the sprite is a placeholder
*/
export declare function isPlaceholderSprite(sprite: EnhancedSprite): boolean;
/**
* Create a placeholder texture that uses minimal memory
*
* @param width - Width of the texture
* @param height - Height of the texture
* @param color - Color of the texture (hex)
* @param renderer - Renderer instance for texture generation
* @returns Placeholder texture
*/
export declare function createPlaceholderTexture(width?: number, height?: number, color?: number, renderer?: Renderer): Texture;
/**
* Replace a fully loaded sprite with a placeholder
*
* @param sprite - Sprite to replace
* @param options - Placeholder options
* @returns New placeholder sprite or null if sprite is invalid
*/
export declare function replaceWithPlaceholder(sprite: EnhancedSprite, options?: Partial<PlaceholderOptions>): EnhancedSprite | null;
/**
* Create a container with a placeholder sprite and optional loading indicator
*
* @param options - Placeholder options
* @param showLoading - Whether to show a loading indicator
* @returns Container with placeholder content
*/
export declare function createPlaceholderContainer(options: PlaceholderOptions, showLoading?: boolean): LoadingContainer;