HarmonyOS 有提供ripper水波纹效果的组件吗,或者第三方的开源Ripper效果?

如题:HarmonyOS 有提供ripper水波纹效果的组件吗,或者第三方的开源Ripper效果?

阅读 484
1 个回答

可参考如下demo:

@Entry
@Component
struct WaterPage {
  @State message: string = 'Hello World';
  @State flag: boolean = false
  @State ballX: number = 0
  @State ballY: number = 0

  build() {
    Column() {
      Column() {

      }.layoutWeight(1).backgroundColor(Color.Pink).width("100%")

      Stack() {
        Button("按钮").width("100%").height("100%").stateEffect(false)
        if (this.flag) {
          Row()
            .width(5)
            .height(5)
            .position({
              x: this.ballX,
              y: this.ballY
            })
            .backgroundColor("rgba(0,0,0,0.7)")
            .transition(TransitionEffect.asymmetric(
              TransitionEffect.IDENTITY,
              TransitionEffect.OPACITY.animation({ duration: 1000, curve: Curve.EaseInOut }).combine(
                TransitionEffect.scale({ x: 100, y: 100 })
              )
            ))
            .borderRadius(15)
        }
      }.width("100%").height(60).clip(true)
      .onClick((e) => {
        this.ballX = e.x - 3
        this.ballY = e.y - 3
        this.flag = !this.flag;
        setTimeout(() => {
          this.flag = !this.flag;
        }, 100)
      })

      Column() {

      }.layoutWeight(1).backgroundColor(Color.Pink).width("100%")
    }
    .width('100%')
    .height('100%')
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进