@ssgoi/core
Version:
Core animation engine for SSGOI - Native app-like page transitions with spring physics
101 lines • 2.91 kB
TypeScript
import { Animator } from './types';
import { NormalizedMultiAnimationConfig, AnimationState } from '../types';
export interface MultiAnimatorOptions {
config: NormalizedMultiAnimationConfig;
from: number;
to: number;
state?: {
position: number;
velocity: number;
};
}
/**
* MultiAnimator - Coordinates multiple animations
*
* Extends Animation base class to provide unified interface.
* Manages the lifecycle and timing of multiple animations.
*
* All scheduling is progress-based using normalizedOffset (0-1):
* - offset 0: Start immediately with previous animation
* - offset 1: Start after previous animation completes
* - offset 0-1: Start when previous animation reaches this progress
*
* Config must be pre-normalized using normalizeSchedule()
*/
export declare class MultiAnimator extends Animator {
private config;
private animators;
private itemOrder;
private completedCount;
private completedAnimators;
private direction;
private idCounter;
private rafId;
private from;
private to;
private initialState;
private constructor();
private generateId;
private initializeAnimators;
/**
* Calculate progress of an animator (0-1)
* Progress = |position - from| / |to - from|
*/
private getAnimatorProgress;
/**
* Get order of springs based on direction
* Forward: 0, 1, 2, ...
* Backward: n-1, n-2, ..., 0
*/
private getOrderedIds;
private onAnimatorComplete;
/**
* Check and start springs based on previous spring's progress
* Called on each frame while animation is running
*/
private checkAndStartSprings;
private startAnimator;
/**
* Start the scheduler loop that checks spring progress
*/
private startScheduler;
private stopScheduler;
private getFirstAnimator;
forward(): void;
backward(): void;
private resetStartedFlags;
stop(): void;
reverse(): void;
getCurrentState(): AnimationState;
/**
* Get current position value from first animator
*/
getCurrentValue(): number;
/**
* Get current velocity from first animator
*/
getVelocity(): number;
/**
* Set position value on first animator
* TODO: Support per-spring control
*/
setValue(value: number): void;
/**
* Set velocity on first animator
* TODO: Support per-spring control
*/
setVelocity(velocity: number): void;
/**
* Check if any animation is currently running
*/
getIsAnimating(): boolean;
/**
* Create MultiAnimator from existing state
* Uses first animator's state for initialization
*/
static fromState(state: {
position: number;
velocity: number;
}, options: Omit<MultiAnimatorOptions, "state">): MultiAnimator;
}
//# sourceMappingURL=multi-animator.d.ts.map