目录

如何在全局自定义Builder中实现动画效果

问题现象

在全局自定义Builder函数中,通过修改组件的属性,如何实现动画效果?问题代码示例参考如下:

@Builder
function bottomViewBuilder() {
  Column() {
    Image($r('app.media.start_branding_light_icon'))
      .width(150)
  }
  .padding({ bottom: AppStorage.get('bottomRectHeight') as number })
  .justifyContent(FlexAlign.End)
  .backgroundColor($r('app.color.background_color_level2'))
  .width(windowWidth)
  .height(windowHeight - adHeight)
  .animation({
    duration: 1000,
    curve: Curve.Linear,
    playMode: PlayMode.Normal
  })
  .onAppear(() => {
  })
}

以上代码中windowWidth、windowHeight、adHeight为全局变量,当全局变量修改时,无法触发动画效果。

背景知识

解决方案