HarmonyOS 如何停止动画,回到初始的静止状态

如何停止动画,回到初始的静止状态

HarmonyOS
2024-12-20 17:11:00
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
superinsect

参考demo:

// xxx.ets
@Entry
@Component
struct AnimateToExample {
  @State widthSize: number = 250
  @State heightSize: number = 100
  @State rotateAngle: number = 0
  private flag: boolean = true
  build() {
    Column() {
      Button('change size')
        .width(this.widthSize)
        .height(this.heightSize)
        .margin(30)
        .onClick(() => {
          if (this.flag) {
            animateTo({
              duration: 2000,
              curve: Curve.EaseOut,
              iterations: 3,
              playMode: PlayMode.Normal,
              onFinish: () => {
                console.info('play end')
              }
            }, () => {
              this.widthSize = 150
              this.heightSize = 60
            })
          } else {
            animateTo({
              duration: 0,
            }, () => {
              this.widthSize = 250
              this.heightSize = 100
            })
          }
          this.flag = !this.flag
          if (!this.flag) {
            animateTo({
              duration: 2000,
              curve: Curve.EaseOut,
              iterations: 3,
              playMode: PlayMode.Normal,
              onFinish: () => {
                console.info('play end')
              }
            }, () => {
              this.widthSize = 150
              this.heightSize = 60
            })
          }
        })
    }.width('100%').margin({ top: 5 })
  }
}
分享
微博
QQ
微信
回复
2024-12-20 18:51:42
相关问题
HarmonyOS 动画如何停止或者取消?
1096浏览 • 1回复 待解决
animateTo动画如何直接停止
3622浏览 • 2回复 待解决
HarmonyOS 如何停止无限旋转中动画
1232浏览 • 1回复 待解决
HarmonyOS动画如何主动停止
1129浏览 • 1回复 待解决
HarmonyOS 怎么停止animateTo动画
662浏览 • 1回复 待解决
HarmonyOS怎么停止animateTo动画
508浏览 • 0回复 待解决
HarmonyOS 属性动画中途如何停止
1262浏览 • 1回复 待解决
HarmonyOS 如何停止一个无限循环动画
1151浏览 • 1回复 待解决
服务卡片进度条如何停止动画
10144浏览 • 1回复 待解决
HarmonyOS animation动画停止位置不对
894浏览 • 1回复 待解决
HarmonyOS 如何回到指定indexpage?
1130浏览 • 1回复 待解决
HarmonyOS 如何使用代码主动回到桌面?
1074浏览 • 1回复 待解决