全球最实用的IT互联网信息网站!

AI人工智能P2P分享&下载搜索网页发布信息网站地图

当前位置:诺佳网 > 电子/半导体 > 接口/总线/驱动 >

鸿蒙开发接口UI界面:【@ohos.animator (动画)】

时间:2024-05-27 16:46

人气:

作者:admin

标签: 接口  鸿蒙 

导读:本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。...

动画

icon-note.gif说明: 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 开发前请熟悉鸿蒙开发指导文档 :[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]

导入模块

import animator from '@ohos.animator';

createAnimator

createAnimator(options: AnimatorOptions): AnimatorResult

定义Animator类。

系统能力: SystemCapability.ArkUI.ArkUI.Full

参数:

参数名类型必填说明
options[AnimatorOptions]定义动画选项,详细请参考AnimatorOptions。

返回值:

类型说明
[AnimatorResult]Animator结果接口。

示例:

< !-- hml -- >
< div class="container" >
  < div class="Animation" style="height: {{divHeight}}px; width: {{divWidth}}px; background-color: red;" onclick="Show" >
  < /div >
< /div >
// js
export default {
  data : {
    divWidth: 200,
    divHeight: 200,
    animator: null
  },
  onInit() {
    var options = {
      duration: 1500,
      easing: 'friction',
      fill: 'forwards',
      iterations: 2,
      begin: 200.0,
      end: 400.0
    };
    this.animator = animator.createAnimator(options);
  },
  Show() {
    var options1 = {
      duration: 2000,
      easing: 'friction',
      fill: 'forwards',
      iterations: 1,
      begin: 200.0,
      end: 400.0
    };
    this.animator.update(options1);
    var _this = this;
    this.animator.onframe = function(value) {
      _this.divWidth = value;
      _this.divHeight = value;
    };
    this.animator.play();
  }
}

AnimatorResult

定义Animator结果接口。

update

update(options: AnimatorOptions): void

更新当前动画器。

系统能力: SystemCapability.ArkUI.ArkUI.Full

参数:

参数名类型必填说明
options[AnimatorOptions]定义动画选项。

示例:

animator.update(options);

play

play(): void

启动动画。

系统能力: SystemCapability.ArkUI.ArkUI.Full

示例:

animator.play();

finish

finish(): void

结束动画。

系统能力: SystemCapability.ArkUI.ArkUI.Full

示例:

animator.finish();

pause

pause(): void

暂停动画。

系统能力: SystemCapability.ArkUI.ArkUI.Full

示例:

animator.pause();

cancel

cancel(): void

删除动画。

系统能力: SystemCapability.ArkUI.ArkUI.Full

示例:

animator.cancel();

reverse

reverse(): void

以相反的顺序播放动画。

系统能力: SystemCapability.ArkUI.ArkUI.Full

示例:

animator.reverse();

onframe

onframe: (progress: number) => void

回调时触发。

系统能力: SystemCapability.ArkUI.ArkUI.Full

参数:

参数名类型必填说明
progressnumber动画的当前进度。

示例:

animator.onframe();

onfinish

onfinish: () => void

动画完成。

系统能力: SystemCapability.ArkUI.ArkUI.Full

示例:

animator.onfinish();

oncancel

oncancel: () => void

动画被取消。

系统能力: SystemCapability.ArkUI.ArkUI.Full

示例:

animator.oncancel();

onrepeat

onrepeat: () => void

系统能力: SystemCapability.ArkUI.ArkUI.Full

示例:

animator.onrepeat();

动画将重复。

AnimatorOptions

定义动画选项。

系统能力: 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full

搜狗高速浏览器截图20240326151450.png

名称HarmonyOSOpenHarmony鸿蒙文档籽料:mau123789是v直接拿参数类型必填说明
durationnumber动画播放的时长,单位毫秒,默认为0。
easingstring动画插值曲线,默认为ease'。
delaynumber动画延时播放时长,单位毫秒,默认为0,即不延时。
fill"none""forwards""backwards"
direction"normal""reverse""alternate"
iterationsnumber动画播放次数,默认值1。设置为0时不播放,设置为-1时无限次播放。
beginnumber动画插值起点,不设置时默认为0。
endnumber动画插值终点,不设置时默认为1。

审核编辑 黄宇

温馨提示:以上内容整理于网络,仅供参考,如果对您有帮助,留下您的阅读感言吧!
相关阅读
本类排行
相关标签
本类推荐

CPU | 内存 | 硬盘 | 显卡 | 显示器 | 主板 | 电源 | 键鼠 | 网站地图

Copyright © 2025-2035 诺佳网 版权所有 备案号:赣ICP备2025066733号
本站资料均来源互联网收集整理,作品版权归作者所有,如果侵犯了您的版权,请跟我们联系。

关注微信