dom-mini.d.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { AnimationPlaybackOptions, Transition, MotionValue, UnresolvedValueKeyframe, ElementOrSelector, DOMKeyframesDefinition, AnimationOptions, GroupAnimationWithThen, AnimationPlaybackControlsWithThen } from 'motion-dom';
  2. type GenericKeyframesTarget<V> = V[] | Array<null | V>;
  3. type ObjectTarget<O> = {
  4. [K in keyof O]?: O[K] | GenericKeyframesTarget<O[K]>;
  5. };
  6. type SequenceTime = number | "<" | `+${number}` | `-${number}` | `${string}`;
  7. type SequenceLabel = string;
  8. interface SequenceLabelWithTime {
  9. name: SequenceLabel;
  10. at: SequenceTime;
  11. }
  12. interface At {
  13. at?: SequenceTime;
  14. }
  15. type MotionValueSegment = [
  16. MotionValue,
  17. UnresolvedValueKeyframe | UnresolvedValueKeyframe[]
  18. ];
  19. type MotionValueSegmentWithTransition = [
  20. MotionValue,
  21. UnresolvedValueKeyframe | UnresolvedValueKeyframe[],
  22. Transition & At
  23. ];
  24. type DOMSegment = [ElementOrSelector, DOMKeyframesDefinition];
  25. type DOMSegmentWithTransition = [
  26. ElementOrSelector,
  27. DOMKeyframesDefinition,
  28. AnimationOptions & At
  29. ];
  30. type ObjectSegment<O extends {} = {}> = [O, ObjectTarget<O>];
  31. type ObjectSegmentWithTransition<O extends {} = {}> = [
  32. O,
  33. ObjectTarget<O>,
  34. AnimationOptions & At
  35. ];
  36. type Segment = ObjectSegment | ObjectSegmentWithTransition | SequenceLabel | SequenceLabelWithTime | MotionValueSegment | MotionValueSegmentWithTransition | DOMSegment | DOMSegmentWithTransition;
  37. type AnimationSequence = Segment[];
  38. interface SequenceOptions extends AnimationPlaybackOptions {
  39. delay?: number;
  40. duration?: number;
  41. defaultTransition?: Transition;
  42. }
  43. declare function animateSequence(definition: AnimationSequence, options?: SequenceOptions): GroupAnimationWithThen;
  44. declare const animateMini: (elementOrSelector: ElementOrSelector, keyframes: DOMKeyframesDefinition, options?: AnimationOptions) => AnimationPlaybackControlsWithThen;
  45. export { animateMini as animate, animateSequence };