未验证 提交 6407491c 编写于 作者: L luoying_ace 提交者: Gitee

update zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-component.md.

Signed-off-by: Nluoying_ace <luoying19@huawei.com>
上级 1e90871d
...@@ -27,37 +27,35 @@ ...@@ -27,37 +27,35 @@
## 示例 ## 示例
示例功能通过一个Button控制第二个Button的出现和消失,并通过transition配置第二个Button出现和消失的过场动画。
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct TransitionExample { struct TransitionExample {
@State btn: boolean = false @State flag: boolean = true
@State show: string = "show" @State show: string = 'show'
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,}) { Column() {
Button(this.show).width(80).height(30).backgroundColor(0x317aff).margin({bottom:50}) Button(this.show).width(80).height(30).margin(30)
.onClick(() => { .onClick(() => {
// 点击Button控制Image的显示和消失
animateTo({ duration: 1000 }, () => { animateTo({ duration: 1000 }, () => {
this.btn = !this.btn if (this.flag) {
if(this.btn){ this.show = 'hide'
this.show = "hide" } else {
}else{ this.show = 'show'
this.show = "show"
} }
this.flag = !this.flag
}) })
}) })
if (this.btn) { if (this.flag) {
// 插入和删除配置为不同的过渡效果 // Image的显示和消失配置为不同的过渡效果
Button() { Image($r('app.media.bg1')).width('80%').height(300)
Image($r('app.media.bg1')).width("80%").height(300) .transition({ type: TransitionType.Insert, scale: { x: 0, y: 1.0 } })
}.transition({ type: TransitionType.Insert, scale : {x:0,y:1.0} }) .transition({ type: TransitionType.Delete, rotate: { angle: 180 } })
.transition({ type: TransitionType.Delete, scale: { x: 1.0, y: 0.0 } })
} }
}.height(400).width("100%").padding({top:100}) }.width('100%')
} }
} }
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册