Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
6b1aab1e
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
6b1aab1e
编写于
10月 27, 2022
作者:
L
luoying_ace
提交者:
Gitee
10月 27, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/application-dev/reference/arkui-ts/ts-animatorproperty.md.
Signed-off-by:
N
luoying_ace
<
luoying19@huawei.com
>
上级
cbda1795
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
59 addition
and
22 deletion
+59
-22
zh-cn/application-dev/reference/arkui-ts/ts-animatorproperty.md
...application-dev/reference/arkui-ts/ts-animatorproperty.md
+59
-22
未找到文件。
zh-cn/application-dev/reference/arkui-ts/ts-animatorproperty.md
浏览文件 @
6b1aab1e
# 属性动画
组件的某些通用属性变化时,可以通过属性动画实现渐变效果,提升用户体验。支持的属性包括width、height、backgroundColor、opacity、scale、rotate、translate等。
组件的某些通用属性变化时,可以通过属性动画实现渐变
过渡
效果,提升用户体验。支持的属性包括width、height、backgroundColor、opacity、scale、rotate、translate等。
> **说明:**
>
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
animation(value: {duration?: number, tempo?: number, curve?: string | Curve | ICurve, delay?:number, iterations: number, playMode?: PlayMode, onFinish?: () => void})
为组件添加属性动画,实现组件属性状态变化时的过渡动画效果。
animation(value: {duration?: number, tempo?: number, curve?: string | Curve | ICurve, delay?:number, iterations: number, playMode?: PlayMode, onFinish?: () => void})
**参数:**
| 名称 | 参数类型 | 必填 | 描述 |
| ---------- | ------------------------------------------| ---- | ------------------------------------------------------------ |
| duration | number | 否 | 设置动画时长。单位为毫秒,默认动画时长为1000毫秒。
<br/>
默认值:1000 |
...
...
@@ -31,34 +29,73 @@ animation(value: {duration?: number, tempo?: number, curve?: string | Curve | IC
@
Entry
@
Component
struct
AttrAnimationExample
{
@
State
widthSize
:
number
=
200
;
@
State
heightSize
:
number
=
100
;
@
State
flag
:
boolean
=
true
;
@
State
widthSize
:
number
=
250
@
State
heightSize
:
number
=
100
@
State
changeColor
:
number
=
0xFF0000FF
@
State
rotateAngle
:
number
=
0
@
State
flagA
:
boolean
=
true
@
State
flagB
:
boolean
=
true
@
State
flagC
:
boolean
=
true
build
()
{
Column
()
{
Button
(
'
c
lick me
'
)
.
onClick
((
event
:
ClickEvent
)
=>
{
if
(
this
.
flag
)
{
Button
(
'
c
hange width and height
'
)
.
onClick
(()
=>
{
if
(
this
.
flag
A
)
{
this
.
widthSize
=
100
this
.
heightSize
=
50
}
else
{
this
.
widthSize
=
2
0
0
this
.
widthSize
=
2
5
0
this
.
heightSize
=
100
}
this
.
flag
=
!
this
.
flag
this
.
flagA
=
!
this
.
flagA
})
.
margin
(
30
)
.
width
(
this
.
widthSize
)
.
height
(
this
.
heightSize
)
.
animation
({
duration
:
2000
,
curve
:
Curve
.
EaseOut
,
delay
:
500
,
iterations
:
1
,
playMode
:
PlayMode
.
Normal
})
Button
(
'
change backgroundColor
'
)
.
onClick
(()
=>
{
if
(
this
.
flagB
)
{
this
.
changeColor
=
0xFFFF4500
}
else
{
this
.
changeColor
=
0xFF0000FF
}
this
.
flagB
=
!
this
.
flagB
})
.
width
(
this
.
widthSize
).
height
(
this
.
heightSize
).
backgroundColor
(
0x317aff
)
.
margin
(
30
)
.
backgroundColor
(
this
.
changeColor
)
.
animation
({
duration
:
2000
,
// 动画时长
curve
:
Curve
.
EaseOut
,
// 动画曲线
delay
:
500
,
// 动画延迟
iterations
:
1
,
// 播放次数
playMode
:
PlayMode
.
Normal
// 动画模式
})
// 对Button组件的宽高属性进行动画配置
}.
width
(
'
100%
'
).
margin
({
top
:
5
})
duration
:
800
,
curve
:
Curve
.
ExtremeDeceleration
,
iterations
:
3
,
playMode
:
PlayMode
.
Normal
})
Button
(
'
change rotate angle
'
)
.
onClick
(()
=>
{
if
(
this
.
flagC
)
{
this
.
rotateAngle
=
90
}
else
{
this
.
rotateAngle
=
0
}
this
.
flagC
=
!
this
.
flagC
})
.
margin
(
30
)
.
rotate
({
angle
:
this
.
rotateAngle
})
.
animation
({
duration
:
1200
,
curve
:
Curve
.
Friction
,
delay
:
500
,
iterations
:
10
,
playMode
:
PlayMode
.
AlternateReverse
})
}.
width
(
'
100%
'
).
margin
({
top
:
20
})
}
}
```
![
zh-cn_image_0000001174264358
](
figures/zh-cn_image_0000001174264358.gif
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录