refresh期望能够自定义loading动画

refresh点击触发刷新组件期望能够自定义刷新动画,可以使用json文件的lottie动画。

tabbar使用refresh组件实现点击刷新,但是无法自定义动画。

HarmonyOS
2024-06-03 23:48:23
1506浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
是潘达不是胖达

使用imageAnimator的实现方式来替换lottie即可。

示例代码:

// xxx.ets 
@Entry 
@Component 
struct RefreshExample { 
  @State isRefreshing: boolean = false 
  @State counter: number = 0 
  @State durationTime: number = 50 //每个数字动画时长,50m 
  @State aniState: AnimationStatus = AnimationStatus.Initial 
 
  @Builder 
  RefreshAnimation() { 
    Column() { 
      ImageAnimator() 
        .images([{ 
          src: 'image/dl_sdk_anim_000.png', 
          duration: this.durationTime 
        }]) 
        .state(this.aniState) 
        .reverse(false) 
        .fillMode(FillMode.Both) 
        .iterations(-1) 
        .width(40) 
        .height(40) 
        .margin({ top: 10 }) 
        .onStart(() => { 
          console.info('LoadingDialog Start') 
        }) 
        .onPause(() => { 
          console.info('LoadingDialog Pause') 
        }) 
        .onRepeat(() => { 
          console.info('LoadingDialog Repeat') 
        }) 
        .onCancel(() => { 
          console.info('LoadingDialog Cancel') 
        }) 
        .onFinish(() => { 
          console.info('LoadingDialog Finish') 
        }) 
    } 
  } 
 
  build() { 
    Column() { 
      Refresh({ refreshing: $$this.isRefreshing, offset: 120, friction: 100, builder: this.RefreshAnimation }) { 
        Text('Pull Down and refresh: ' + this.counter) 
          .fontSize(30) 
          .margin(10) 
      } 
      .onStateChange((refreshStatus: RefreshStatus) => { 
        console.info('Refresh onStatueChange state is ' + refreshStatus) 
      }) 
      .onRefreshing(() => { 
        this.aniState = AnimationStatus.Running 
        setTimeout(() => { 
          this.counter++ 
          this.isRefreshing = false 
          this.aniState = AnimationStatus.Stopped 
        }, 1000) 
        console.log('onRefreshing test') 
      }) 
    } 
  } 
}
  • 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.
分享
微博
QQ
微信
回复
2024-06-04 22:40:30


相关问题
HarmonyOS Refresh自定义刷新样式
822浏览 • 1回复 待解决
自定义弹窗自定义转场动画
1949浏览 • 1回复 待解决
HarmonyOS 自定义Refresh头部展示不全
573浏览 • 1回复 待解决
CustomDialog自定义动画
1344浏览 • 1回复 待解决
能够提供HarmonyOS自定义相机案例吗?
1152浏览 • 1回复 待解决
是否能够自定义router跳转的url
1543浏览 • 1回复 待解决
CustomDialog不支持自定义动画
1192浏览 • 2回复 待解决
如何实现自定义应用入场动画
1680浏览 • 1回复 待解决
Navigation如何自定义立体转场动画
314浏览 • 1回复 待解决
弹窗打开、关闭动画是否支持自定义
3339浏览 • 1回复 待解决
swiper组件如何实现自定义切换动画
1977浏览 • 1回复 待解决