-
Notifications
You must be signed in to change notification settings - Fork 207
ObjectAnimationDemo.ag
xu_whale edited this page Sep 7, 2020
·
1 revision
copy下面代码,运行试试
model(userData)
positionXAnim() {
type = PositionX,
from = 200,
to = 10,
repeatCount = 3,
duration = 2,
delay = 0,
timing = Spring,
spring = { Bounciness = 10 },
start = userData.animStatus.start,
pause = userData.animStatus.pause,
resume = userData.animStatus.resume,
stop = userData.animStatus.stop,
}
---
--- UI
ui {
--- layout views
Label("点我开Color动画")
.padding(10, 30, 10, 30)
.bgColor(Color(0xaaaaaa))
.onClick(function()
--方式1
anim = ObjectAnimation(AnimProperty.Color, self)
anim.duration(2).from(200, 200, 0, 1).to(0, 0, 200, 1)
anim.start()
end)
,
Label("positionX动画")
.top(50)
.height(100)
.bgColor(Color(0xafaff0))
--添加动画
.animation(positionXAnim())
,
Label("点我开始positionX动画")
.top(20)
.padding(10, 30, 10, 30)
.bgColor(Color(0xaaaaaa))
.onClick(function()
--方式2
userData.animStatus.start = true
end)
,
Label("点我暂停positionX动画")
.top(20)
.padding(10, 30, 10, 30)
.bgColor(Color(0xaaaaaa))
.onClick(function()
userData.animStatus.start = false
userData.animStatus.pause = true
end)
}.safeArea(SafeArea.TOP)
---
--- preview
local function preview()
userData.animStatus = {
start = false,
pause = false,
resume = false,
stop = false }
end