UNPKG

kinetic-slider

Version:

A WebGL-powered kinetic slider component using PIXI.js

99 lines (97 loc) 4.22 kB
// src/components/KineticSlider/managers/UpdateTypes.ts /** * @file UpdateTypes.ts * @description Defines standard update types and their recommended priorities for KineticSlider. * This helps maintain consistent priority assignments across different hooks and components. */ /** * Priority levels for rendering updates. * Higher numbers indicate higher priority. * @enum {number} */ var UpdatePriority; (function (UpdatePriority) { /** Background, non-visual updates */ UpdatePriority[UpdatePriority["LOW"] = 0] = "LOW"; /** Standard visual updates */ UpdatePriority[UpdatePriority["NORMAL"] = 1] = "NORMAL"; /** Important visual feedback */ UpdatePriority[UpdatePriority["HIGH"] = 2] = "HIGH"; /** Must-run-immediately updates */ UpdatePriority[UpdatePriority["CRITICAL"] = 3] = "CRITICAL"; })(UpdatePriority || (UpdatePriority = {})); /** * Standard update types for KineticSlider with associated default priorities. * @enum {string} */ var UpdateType; (function (UpdateType) { /** Background animation effects that aren't immediately visible */ UpdateType["BACKGROUND_EFFECT"] = "background_effect"; /** Preloading of assets not yet needed */ UpdateType["ASSET_PRELOAD"] = "asset_preload"; /** Standard text movement and position updates */ UpdateType["TEXT_POSITION"] = "text_position"; /** Idle effects that show after some time */ UpdateType["IDLE_EFFECT"] = "idle_effect"; /** Filter updates that aren't critical to user interaction */ UpdateType["FILTER_UPDATE"] = "filter_update"; /** Updates directly responding to mouse movement */ UpdateType["MOUSE_RESPONSE"] = "mouse_response"; /** Displacement effects tied to user interaction */ UpdateType["DISPLACEMENT_EFFECT"] = "displacement_effect"; /** Main slide position and scale during interaction */ UpdateType["SLIDE_TRANSFORM"] = "slide_transform"; /** Slide transitions between views */ UpdateType["SLIDE_TRANSITION"] = "slide_transition"; /** Direct user interaction responses */ UpdateType["INTERACTION_FEEDBACK"] = "interaction_feedback"; /** Loading state changes that affect UI */ UpdateType["LOADING_STATE"] = "loading_state"; })(UpdateType || (UpdateType = {})); /** * Maps update types to their recommended priority levels. * This provides consistency across the application. * @type {Record<UpdateType, UpdatePriority>} */ const UPDATE_TYPE_PRIORITIES = { // Low priority (background tasks) [UpdateType.BACKGROUND_EFFECT]: UpdatePriority.LOW, [UpdateType.ASSET_PRELOAD]: UpdatePriority.LOW, // Normal priority (standard visual updates) [UpdateType.TEXT_POSITION]: UpdatePriority.NORMAL, [UpdateType.IDLE_EFFECT]: UpdatePriority.NORMAL, [UpdateType.FILTER_UPDATE]: UpdatePriority.NORMAL, // High priority (important visual feedback) [UpdateType.MOUSE_RESPONSE]: UpdatePriority.HIGH, [UpdateType.DISPLACEMENT_EFFECT]: UpdatePriority.HIGH, [UpdateType.SLIDE_TRANSFORM]: UpdatePriority.HIGH, // Critical priority (must execute immediately) [UpdateType.SLIDE_TRANSITION]: UpdatePriority.CRITICAL, [UpdateType.INTERACTION_FEEDBACK]: UpdatePriority.CRITICAL, [UpdateType.LOADING_STATE]: UpdatePriority.CRITICAL }; /** * Helper function to get the recommended priority for an update type. * * @param {UpdateType} type - The type of update * @returns {UpdatePriority} The recommended priority level */ function getPriorityForUpdateType(type) { return UPDATE_TYPE_PRIORITIES[type] || UpdatePriority.NORMAL; } /** * Generate a unique update ID for a specific component and update type. * * @param {string} componentId - ID of the component requesting the update * @param {UpdateType} updateType - Type of update * @param {string} [suffix] - Optional suffix for further differentiation * @returns {string} A unique update ID */ function createUpdateId(componentId, updateType, suffix) { return suffix ? `${componentId}:${updateType}:${suffix}` : `${componentId}:${updateType}`; } export { UPDATE_TYPE_PRIORITIES, UpdatePriority, UpdateType, createUpdateId, getPriorityForUpdateType }; //# sourceMappingURL=UpdateTypes.js.map