Function animationAsync

  • 创建动画,对Tween的封装,返回一个promise,动画结束后返回

    Type Parameters

    • T extends Record<string, any>

    Parameters

    • props: {
          autoPlay?: boolean;
          by?: boolean;
          delay?: number;
          duration: number;
          easing?: Easing;
          from?: T;
          id?: string;
          onComplete?: ((target, isEnd, isStop) => void);
          onProgress?: ((target, key, start, end, alpha, reversed) => boolean | void);
          onStart?: ((target) => void);
          onUpdate?: ((target) => void);
          repeatForever?: boolean;
          repeatTimes?: number;
          tag?: string;
          to?: T;
          yoyoForever?: boolean;
          yoyoTimes?: number;
      }
      • Optional autoPlay?: boolean

        自动播放动画,默认是

      • Optional by?: boolean

        为true的时候,to的值为相对值

      • Optional delay?: number

        延迟时长

      • duration: number

        持续时长

      • Optional easing?: Easing

        easing 默认 linear

      • Optional from?: T

        开始值(默认{value: 0})

      • Optional id?: string

        id

      • Optional onComplete?: ((target, isEnd, isStop) => void)

        A callback function to execute when the animation completes.

        Param: target

        The target object that was tweened.

          • (target, isEnd, isStop): void
          • A callback function to execute when the animation completes.

            Parameters

            • target: T

              The target object that was tweened.

            • isEnd: boolean
            • isStop: boolean

            Returns void

      • Optional onProgress?: ((target, key, start, end, alpha, reversed) => boolean | void)

        A callback function to be executed before each property is updated.

        Param: target

        The target object that is being tweened.

        Param: key

        The key or property being animated.

        Param: start

        The initial value of the animated property.

        Param: end

        The final value of the animated property.

        Param: alpha

        The current animation progress as a normalized value (0 to 1).

        Returns

        If false, will not assign a new value to the property.

          • (target, key, start, end, alpha, reversed): boolean | void
          • A callback function to be executed before each property is updated.

            Parameters

            • target: T

              The target object that is being tweened.

            • key: string

              The key or property being animated.

            • start: AllowedTypes

              The initial value of the animated property.

            • end: AllowedTypes

              The final value of the animated property.

            • alpha: number

              The current animation progress as a normalized value (0 to 1).

            • reversed: boolean

            Returns boolean | void

            If false, will not assign a new value to the property.

      • Optional onStart?: ((target) => void)

        A callback function to execute when the animation starts.

        Param: target

        The target object that is being tweened.

          • (target): void
          • A callback function to execute when the animation starts.

            Parameters

            • target: T

              The target object that is being tweened.

            Returns void

      • Optional onUpdate?: ((target) => void)

        A callback function to be executed after each property has been updated.

        Param: target

        The target object that is being tweened.

          • (target): void
          • A callback function to be executed after each property has been updated.

            Parameters

            • target: T

              The target object that is being tweened.

            Returns void

      • Optional repeatForever?: boolean

        重复循环

      • Optional repeatTimes?: number

        重复次数

      • Optional tag?: string

        分类

      • Optional to?: T

        结束值(默认{value: 1)

      • Optional yoyoForever?: boolean

        是否往返循环

      • Optional yoyoTimes?: number

        往返次数

    Returns Promise<unknown>