dialog底部弹起动画,想问下arkts如何实现控制dialog弹起收回的动画效果

想问下arkts如何实现控制dialog弹起收回的动画效果。

HarmonyOS
2024-09-23 13:47:59
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa

参考如下demo:

let anmDuration: number = 800;  
  
// 弹窗交互  
@CustomDialog  
struct CustomDialogExample {  
  
  controller: CustomDialogController = new CustomDialogController({  
    builder: CustomDialogExample({}),  
    autoCancel:false  
  })  
  
  @State showFlag: Visibility = Visibility.Visible;  
  @State isAutoCancel: boolean = false;  
  
  build() {  
    Column() {  
      Text('点我关闭弹窗').fontSize(20).margin({ top: 10, bottom: 10 })  
        .backgroundColor('#FFFFFF')  
        .textAlign(TextAlign.Center)  
        .height(200)  
        .width('100%')  
        .margin({top:600})  
        .onClick(()=>{  
          this.cancel();  
        })  
    }  
    .width('100%')  
    .height('100%')  
    .margin({  
      bottom: -15  
    })  
    .onClick(()=>{  
      if(this.isAutoCancel){  
        this.cancel();  
      }  
    })  
    .visibility(this.showFlag)  
    .transition(TransitionEffect.OPACITY.animation({duration: anmDuration}).combine(TransitionEffect.translate({y: 100})))  
  }  
  
  cancel(){  
    this.showFlag=Visibility.Hidden  
    setTimeout(()=>{  
      this.controller.close()  
    }, anmDuration)  
  }  
}  
@Entry  
@Component  
struct CustomDialogUser {  
  @State isAutoCancel: boolean = false;  
  
  dialogController: CustomDialogController = new CustomDialogController({  
    builder: CustomDialogExample({ isAutoCancel: this.isAutoCancel }),  
    autoCancel: this.isAutoCancel,  
    customStyle:true  
  })  
  
  build() {  
    Column() {  
      Button('click me')  
        .onClick(() => {  
          this.dialogController.open()  
        })  
    }.width('100%').height('100%').margin({ top: 5 })  
    .onClick(()=>{  
    })  
  }  
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
分享
微博
QQ
微信
回复
2024-09-23 18:32:06
相关问题
HarmonyOS Navigation实现Dialog转场动画
711浏览 • 1回复 待解决
如何定义dialog动画,有人知道吗?
2944浏览 • 1回复 待解决
属性动画如何实现宽高动画效果
2940浏览 • 1回复 待解决
如何实现动画转场效果
1765浏览 • 1回复 待解决
如何实现list折叠动画效果
1351浏览 • 1回复 待解决
文字动画效果如何实现
3015浏览 • 0回复 待解决
Harmony next 子窗口实现dialog效果
281浏览 • 0回复 待解决
如何实现底部缓慢上升弹窗动画
2506浏览 • 1回复 待解决
如何实现全局dialog
1455浏览 • 1回复 待解决
渐变动画效果如何实现
287浏览 • 0回复 待解决
HarmonyOS 动画效果实现
1075浏览 • 1回复 待解决