animation.d.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { KeyValue, Timing, Interp } from '@antv/x6-common';
  2. import { Cell } from './cell';
  3. export declare class Animation {
  4. protected readonly cell: Cell;
  5. protected readonly ids: {
  6. [path: string]: number;
  7. };
  8. protected readonly cache: {
  9. [path: string]: {
  10. startValue: any;
  11. targetValue: any;
  12. options: Animation.StartOptions<any>;
  13. };
  14. };
  15. constructor(cell: Cell);
  16. get(): string[];
  17. start<T extends Animation.TargetValue>(path: string | string[], targetValue: T, options?: Animation.StartOptions<T>, delim?: string): () => void;
  18. stop<T extends Animation.TargetValue>(path: string | string[], options?: Animation.StopOptions<T>, delim?: string): this;
  19. private clean;
  20. private getTiming;
  21. private getInterp;
  22. private getArgs;
  23. }
  24. export declare namespace Animation {
  25. interface BaseOptions {
  26. delay: number;
  27. duration: number;
  28. timing: Timing.Names | Timing.Definition;
  29. }
  30. type TargetValue = string | number | KeyValue<number>;
  31. interface CallbackArgs<T> {
  32. cell: Cell;
  33. path: string;
  34. startValue: T;
  35. targetValue: T;
  36. }
  37. interface ProgressArgs<T> extends CallbackArgs<T> {
  38. progress: number;
  39. currentValue: T;
  40. }
  41. interface StopArgs<T> extends CallbackArgs<T> {
  42. jumpedToEnd?: boolean;
  43. }
  44. interface StartOptions<T> extends Partial<BaseOptions>, StopOptions<T> {
  45. interp?: Interp.Definition<any>;
  46. /**
  47. * A function to call when the animation begins.
  48. */
  49. start?: (options: CallbackArgs<T>) => void;
  50. /**
  51. * A function to be called after each step of the animation, only once per
  52. * animated element regardless of the number of animated properties.
  53. */
  54. progress?: (options: ProgressArgs<T>) => void;
  55. }
  56. interface StopOptions<T> {
  57. /**
  58. * A Boolean indicating whether to complete the animation immediately.
  59. * Defaults to `false`.
  60. */
  61. jumpedToEnd?: boolean;
  62. /**
  63. * A function that is called once the animation completes.
  64. */
  65. complete?: (options: CallbackArgs<T>) => void;
  66. /**
  67. * A function to be called when the animation stops.
  68. */
  69. stop?: (options: StopArgs<T>) => void;
  70. /**
  71. * A function to be called when the animation completes or stops.
  72. */
  73. finish?: (options: CallbackArgs<T>) => void;
  74. }
  75. const defaultOptions: BaseOptions;
  76. }