Animator.d.ts 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import Clip from './Clip';
  2. import { ArrayLike, Dictionary } from '../core/types';
  3. import { AnimationEasing } from './easing';
  4. import Animation from './Animation';
  5. declare type NumberArray = ArrayLike<number>;
  6. declare type InterpolatableType = string | number | NumberArray | NumberArray[];
  7. export declare function cloneValue(value: InterpolatableType): number | any[];
  8. declare type ValueType = 0 | 1 | 2 | 3 | 4 | 5 | 6;
  9. declare type Keyframe = {
  10. time: number;
  11. value: unknown;
  12. percent: number;
  13. rawValue: unknown;
  14. easing?: AnimationEasing;
  15. easingFunc?: (percent: number) => number;
  16. additiveValue?: unknown;
  17. };
  18. declare class Track {
  19. keyframes: Keyframe[];
  20. propName: string;
  21. valType: ValueType;
  22. discrete: boolean;
  23. _invalid: boolean;
  24. private _finished;
  25. private _needsSort;
  26. private _additiveTrack;
  27. private _additiveValue;
  28. private _lastFr;
  29. private _lastFrP;
  30. constructor(propName: string);
  31. isFinished(): boolean;
  32. setFinished(): void;
  33. needsAnimate(): boolean;
  34. getAdditiveTrack(): Track;
  35. addKeyframe(time: number, rawValue: unknown, easing?: AnimationEasing): Keyframe;
  36. prepare(maxTime: number, additiveTrack?: Track): void;
  37. step(target: any, percent: number): void;
  38. private _addToTarget;
  39. }
  40. declare type DoneCallback = () => void;
  41. declare type AbortCallback = () => void;
  42. export declare type OnframeCallback<T> = (target: T, percent: number) => void;
  43. export declare type AnimationPropGetter<T> = (target: T, key: string) => InterpolatableType;
  44. export declare type AnimationPropSetter<T> = (target: T, key: string, value: InterpolatableType) => void;
  45. export default class Animator<T> {
  46. animation?: Animation;
  47. targetName?: string;
  48. scope?: string;
  49. __fromStateTransition?: string;
  50. private _tracks;
  51. private _trackKeys;
  52. private _target;
  53. private _loop;
  54. private _delay;
  55. private _maxTime;
  56. private _force;
  57. private _paused;
  58. private _started;
  59. private _allowDiscrete;
  60. private _additiveAnimators;
  61. private _doneCbs;
  62. private _onframeCbs;
  63. private _abortedCbs;
  64. private _clip;
  65. constructor(target: T, loop: boolean, allowDiscreteAnimation?: boolean, additiveTo?: Animator<any>[]);
  66. getMaxTime(): number;
  67. getDelay(): number;
  68. getLoop(): boolean;
  69. getTarget(): T;
  70. changeTarget(target: T): void;
  71. when(time: number, props: Dictionary<any>, easing?: AnimationEasing): this;
  72. whenWithKeys(time: number, props: Dictionary<any>, propNames: string[], easing?: AnimationEasing): this;
  73. pause(): void;
  74. resume(): void;
  75. isPaused(): boolean;
  76. duration(duration: number): this;
  77. private _doneCallback;
  78. private _abortedCallback;
  79. private _setTracksFinished;
  80. private _getAdditiveTrack;
  81. start(easing?: AnimationEasing): this;
  82. stop(forwardToLast?: boolean): void;
  83. delay(time: number): this;
  84. during(cb: OnframeCallback<T>): this;
  85. done(cb: DoneCallback): this;
  86. aborted(cb: AbortCallback): this;
  87. getClip(): Clip;
  88. getTrack(propName: string): Track;
  89. getTracks(): Track[];
  90. stopTracks(propNames: string[], forwardToLast?: boolean): boolean;
  91. saveTo(target: T, trackKeys?: readonly string[], firstOrLast?: boolean): void;
  92. __changeFinalValue(finalProps: Dictionary<any>, trackKeys?: readonly string[]): void;
  93. }
  94. export declare type AnimatorTrack = Track;
  95. export {};