当前位置:网站首页>ArkUI中的显式动画
ArkUI中的显式动画
2022-07-27 09:08:00 【华为云】
在任何系统的UI框架中,动画实现的原理都是相同的,即:在一段时间内,快速地多次改变UI外观;由于人眼会产生视觉暂留,所以最终看到的就是一个“连续”的动画,这和电影的原理是一样的。换言之,动画是“画出来的动”,关键不在于“画”的来源,而在于“动”的来源,如果这种动是记录了现实中发生过的运动,那它就是电影,如果这种动在现实中不曾存在,那它就是动画。
这一节带大家来了解动画相关的内容
显式动画
显式动画
显示动画由全局方法 animateTo 实现,我们来看一下他的数学
value:设置动画的具体配置参数,
AnimateParam说明如下:duration:设置动画的执行时长,单位为毫秒,默认为 1000 毫秒。
tempo:设置动画的播放速度,值越大动画播放越快,值越小播放越慢,默认值为 1 ,为 0 时无动画效果。
curve:设置动画曲线,默认值为
Linear。delay:设置动画的延迟执行时间,单位为毫秒,默认值为 0 不延迟。
iterations:设置动画的执行次数,默认值为 1 次,设置为 -1 时无限循环。
playMode:设置动画播放模式,默认播放完成后重头开始播放。
onFinish:动画播放完成的回调。
event:指定显示动效的闭包函数,在闭包函数中导致的状态变化系统会自动插入过渡动画。
下面是演示

源代码如下:
import router from '@system.router'@[email protected] Index { @State message: string = 'OpenHarmony之旅' @State btnWidth: number = 330; @State btnHeight: number = 80; @State btnAnim: boolean = true; build() { Row() { Column() { Button(this.message) .size({ width: this.btnWidth, height: this.btnHeight }) .fontSize(20) .backgroundColor(Color.Orange) .fontStyle(FontStyle.Italic) .fontWeight(FontWeight.Bold) .onClick(() => { if (this.btnAnim) { animateTo({ onFinish: () => { console.log("动画已完成") } }, () => { this.btnWidth = 159; this.btnHeight = 50; }); } else { animateTo({ onFinish: () => { } }, () => { this.btnWidth = 200; this.btnHeight = 60; }); } this.btnAnim = !this.btnAnim; }) } .width('100%') } .height('100%') }}边栏推荐
- pollFirst(),pollLast(),peekFirst(),peekLast()
- PyTorch自定义CUDA算子教程与运行时间分析
- 微信安装包从0.5M暴涨到260M,为什么我们的程序越来越大?
- C# 窗体应用常用基础控件讲解(适合萌新)
- HUAWEI 机试题:字符串变换最小字符串 js
- PyQt5快速开发与实战 4.1 QMainWindow
- [micro service ~sentinel] sentinel dashboard control panel
- Mangodb简单使用
- The execution sequence of async/await, macro tasks and micro tasks
- 693. Travel sequencing
猜你喜欢

Pytorch custom CUDA operator tutorial and runtime analysis

Linux Installation and remote connection MySQL records

BEVFormer: Learning Bird’s-Eye-View Representation from Multi-Camera Images via Spatiotemporal Trans
![[interprocess communication IPC] - semaphore learning](/img/47/b76c329e748726097219abce28fce8.png)
[interprocess communication IPC] - semaphore learning

NIO总结文——一篇读懂NIO整个流程

How to optimize the deep learning model to improve the reasoning speed

Babbitt | yuan universe daily must read: Guangzhou Nansha released the "Yuan universe nine" measures, and the platform can obtain up to 200million yuan of financial support

Five kinds of 2D attention finishing (non local, criss cross, Se, CBAM, dual attention)

Hangzhou E-Commerce Research Institute released an explanation of the new term "digital existence"

被三星和台积电挤压的Intel终放下身段,为中国芯片定制芯片工艺
随机推荐
【每日算法Day 94】经典面试题:机器人的运动范围
B tree
redis 网络IO
易语言编程: 让读屏软件可获取标签控件的文本
02 linear structure 3 reversing linked list
Tensorflow模型训练和评估的内置方法
NiO Summary - read and understand the whole NiO process
Restful
500报错
2036: [Blue Bridge Cup 2022 preliminary] statistical submatrix (two-dimensional prefix sum, one-dimensional prefix sum)
How to deploy yolov6 with tensorrt
linux下安装oracle,本地PL/SQL连接Linux下的oracle导入表并新建用户和密码
ctfshow 终极考核
Babbitt | yuan universe daily must read: Guangzhou Nansha released the "Yuan universe nine" measures, and the platform can obtain up to 200million yuan of financial support
qt中使用sqlite同时打开多个数据库文件
async/await的执行顺序以及宏任务和微任务
接口测试工具-Jmeter压力测试使用
Aruba learning notes 10 security authentication portal authentication (web page configuration)
[I2C reading mpu6050 of Renesas ra6m4 development board]
"Weilai Cup" 2022 Niuke summer multi school training camp 1