@ssgoi/core
Version:
Core animation engine for SSGOI - Native app-like page transitions with spring physics
58 lines • 1.81 kB
TypeScript
import { StyleObject } from './runner/types';
import { AnimationState, PhysicsOptions } from '../types';
import { Animator } from './types';
export type { StyleObject };
export interface AnimatorOptions {
from?: number;
to?: number;
physics?: PhysicsOptions;
tick?: (progress: number) => void;
css?: {
element: HTMLElement;
style: (progress: number) => StyleObject;
};
onComplete?: () => void;
onStart?: () => void;
}
/**
* SingleAnimator - Spring-based Animation Controller for single spring
*
* High-level API that accepts spring config or integrator factory.
* Internally creates Integrator and selects appropriate runner.
*
* - tick: RAF-based real-time animation
* - css: Web Animation API based (GPU accelerated, velocity tracking via simulation data)
*/
export declare class SingleAnimator extends Animator {
private options;
private runner;
private controls;
private isAnimating;
private currentValue;
private currentVelocity;
private updateFn;
constructor(options: AnimatorOptions);
/**
* Sync element state to current progress value
* Uses the update callback if provided
*/
syncState(): void;
/**
* Create Integrator from physics options
* Priority: integrator factory > inertia/spring config > default spring
*/
private createIntegrator;
private runAnimation;
forward(): void;
backward(): void;
reverse(): void;
stop(): void;
getVelocity(): number;
getCurrentValue(): number;
getIsAnimating(): boolean;
getCurrentState(): AnimationState;
setValue(value: number): void;
setVelocity(velocity: number): void;
updateOptions(newOptions: Partial<AnimatorOptions>): void;
}
//# sourceMappingURL=single-animator.d.ts.map