HarmonyOS Refresh支持swiper吗

使用swiper做了一个上下滑动页面,需要有下拉刷新功能,貌似refrsh不支持swiper

HarmonyOS
2024-12-20 15:22:01
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Excelsior_abit

参考demo:

@Entry
@Component
struct SwiperItemLeak {
  private swiperController: SwiperController = new SwiperController()
  private curSwiperIndex = 0;
  private list: number[] = []
  @State isStopSwiperSlide: boolean = false;
  @State positionY: number = 0;
  private isRefresh: boolean = false;

  aboutToAppear(): void {
    for (let i = 1; i <= 10; i++) {
      this.list.push(i);
    }
  }

  build() {
    Stack({ alignContent: Alignment.TopStart }) {
      Text(this.positionY.toString())
        .width('100%')
        .height('10%')
        .textAlign(TextAlign.Center)
        .fontSize(30)
      Swiper(this.swiperController) {
        ForEach(this.list, (item: number) => {
          Text(item.toString())
            .width('100%')
            .height('100%')
            .backgroundColor(0xAFEEEE * ((item + 1) / 0x0f))
            .textAlign(TextAlign.Center)
            .fontSize(30)
        })
      }
      .vertical(true)
      .width("100%")
      .height("100%")
      .cachedCount(3)
      .index(0)
      .autoPlay(false)
      .indicator(false)
      .effectMode(EdgeEffect.None)
      .loop(false)
      .duration(100)
      .disableSwipe(this.isStopSwiperSlide)
      .displayCount(1)
      .itemSpace(0)
      .curve(Curve.Linear)
      .backgroundColor(Color.Red)
      .position({ y: this.positionY })
      .onChange((index: number) => {
        console.info(index.toString())
        this.curSwiperIndex = index;
      })
      .parallelGesture(
        PanGesture()
          .onActionStart((event: GestureEvent) => {
          })
          .onActionUpdate((event: GestureEvent) => {
            if (event && this.curSwiperIndex == 0) {
              if (event.offsetY > 0) {
                this.positionY = event.offsetY;
                this.isStopSwiperSlide = true;
                this.isRefresh = true;
              }
              else {
                this.positionY = 0;
                this.isStopSwiperSlide = false;
                this.isRefresh = false;
              }
            }
          })
          .onActionEnd(() => {
            if (this.isRefresh) {
              setTimeout(() => {
                this.isStopSwiperSlide = false;
                this.positionY = 0;
                this.isRefresh = false;
              }, 1000);
            }
          })
      )
    }.width('100%').height("100%").backgroundColor(Color.Pink)
  }
}
  • 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.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
分享
微博
QQ
微信
回复
2024-12-20 17:41:12
相关问题
litewearable支持swiper
3074浏览 • 1回复 待解决
HarmonyOS Swiper支持动态修改数据
1228浏览 • 1回复 待解决
Swiper的indicator后续会支持自定义
2815浏览 • 1回复 待解决
Refresh组件不支持设置nestedScroll属性
2719浏览 • 1回复 待解决
Swiper是否支持组件复用
1531浏览 • 1回复 待解决
HarmonyOS Refresh + Web?
536浏览 • 0回复 待解决
HarmonyOS Refresh禁用下拉
701浏览 • 1回复 待解决
HarmonyOS Refresh组件使用问题
778浏览 • 1回复 待解决
HarmonyOS Refresh或PullToRefresh手动刷新
620浏览 • 1回复 待解决
HarmonyOS Refresh组件disable的功能
490浏览 • 1回复 待解决
HarmonyOS 支持VPN
763浏览 • 1回复 待解决
HarmonyOS使用Refresh下拉刷新问题
1534浏览 • 1回复 待解决
HarmonyOS Refresh自定义刷新样式
817浏览 • 1回复 待解决