From 75df183bcc263c84b90f217b002490a810bb79c1 Mon Sep 17 00:00:00 2001 From: wangyingjun02 <2959448004@qq.com> Date: Wed, 5 Jul 2023 10:01:46 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E7=BB=84=E4=BB=B6=E5=9C=A8?= =?UTF-8?q?=E4=BD=8E=E7=89=88=E6=9C=AC=E9=95=9C=E5=83=8F=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E5=88=B7=E6=96=B0=E9=97=AA=E9=80=80=E9=97=AE?= =?UTF-8?q?=E9=A2=98=202.=E9=80=82=E9=85=8D=EF=BC=9ADevEco=20Studio:=204.0?= =?UTF-8?q?=20Canary1(4.0.0.112),=20SDK:=20API10=20(4.0.7.2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyingjun02 <2959448004@qq.com> --- PullToRefresh/oh-package.json5 | 2 +- .../PullToRefresh/PullToRefresh.ets | 57 +++++++++++++------ README.md | 2 +- build-profile.json5 | 14 ++++- changelog.md | 6 ++ entry/oh-package.json5 | 2 +- hvigor/hvigor-config.json5 | 4 +- oh-package.json5 | 2 +- 8 files changed, 63 insertions(+), 26 deletions(-) diff --git a/PullToRefresh/oh-package.json5 b/PullToRefresh/oh-package.json5 index 43d9baa..e5029a4 100644 --- a/PullToRefresh/oh-package.json5 +++ b/PullToRefresh/oh-package.json5 @@ -14,7 +14,7 @@ "main": "index.ets", "repository": "https://gitee.com/openharmony-sig/PullToRefresh", "type": "module", - "version": "2.0.2", + "version": "2.0.3", "dependencies": {}, "tags": [ "UI" diff --git a/PullToRefresh/src/main/ets/components/PullToRefresh/PullToRefresh.ets b/PullToRefresh/src/main/ets/components/PullToRefresh/PullToRefresh.ets index 055567c..5654dd9 100644 --- a/PullToRefresh/src/main/ets/components/PullToRefresh/PullToRefresh.ets +++ b/PullToRefresh/src/main/ets/components/PullToRefresh/PullToRefresh.ets @@ -263,24 +263,47 @@ export struct PullToRefresh { this.listOffsetNew = this.scroller.currentOffset().yOffset; // 列表处于底部位置且上滑时,2.已上滑时 // @ts-ignore - if ((this.state == IS_FREE && this.listOffsetOld == this.listOffsetNew && this.listOffsetOld != 0 && this.touchYNew < this.touchYOld && this.scroller.isAtEnd()) || - this.state == IS_PULL_UP_1 || this.state == IS_PULL_UP_2) { - // 获取最新的位移距离 - var trY = this.touchYNew - this.touchYOld; - // 计算当前需要位移的总距离 - this.trYBottom = this.getTranslateYOfLoadMore(trY); - if (this.trYBottom > -this.refreshConfigurator.getLoadImgHeight()) { - this.state = IS_PULL_UP_1; - } else { - this.state = IS_PULL_UP_2; - } - // 如果没有自定义加载更多动画,就执行内置动画上拉时的逻辑 - if (!this.customLoad) { - this.drawLoadView(true, -this.trYBottom / this.refreshConfigurator.getMaxTranslate()); + try { + if ((this.state == IS_FREE && this.listOffsetOld == this.listOffsetNew && this.listOffsetOld != 0 && this.touchYNew < this.touchYOld && this.scroller.isAtEnd()) || + this.state == IS_PULL_UP_1 || this.state == IS_PULL_UP_2) { + // 获取最新的位移距离 + var trY = this.touchYNew - this.touchYOld; + // 计算当前需要位移的总距离 + this.trYBottom = this.getTranslateYOfLoadMore(trY); + if (this.trYBottom > -this.refreshConfigurator.getLoadImgHeight()) { + this.state = IS_PULL_UP_1; + } else { + this.state = IS_PULL_UP_2; + } + // 如果没有自定义加载更多动画,就执行内置动画上拉时的逻辑 + if (!this.customLoad) { + this.drawLoadView(true, -this.trYBottom / this.refreshConfigurator.getMaxTranslate()); + } + // 如果有上拉中动画回调,就执行上拉中动画回调 + if (this.onAnimPullUp) { + this.onAnimPullUp(-this.trYBottom / this.refreshConfigurator.getMaxTranslate(), this.mWidthNumber, -this.trYBottom); + } } - // 如果有上拉中动画回调,就执行上拉中动画回调 - if (this.onAnimPullUp) { - this.onAnimPullUp(-this.trYBottom / this.refreshConfigurator.getMaxTranslate(), this.mWidthNumber, -this.trYBottom); + }catch (error){ + if ((this.state == IS_FREE && this.listOffsetOld == this.listOffsetNew && this.listOffsetOld != 0 && this.touchYNew < this.touchYOld) || + this.state == IS_PULL_UP_1 || this.state == IS_PULL_UP_2) { + // 获取最新的位移距离 + var trY = this.touchYNew - this.touchYOld; + // 计算当前需要位移的总距离 + this.trYBottom = this.getTranslateYOfLoadMore(trY); + if (this.trYBottom > -this.refreshConfigurator.getLoadImgHeight()) { + this.state = IS_PULL_UP_1; + } else { + this.state = IS_PULL_UP_2; + } + // 如果没有自定义加载更多动画,就执行内置动画上拉时的逻辑 + if (!this.customLoad) { + this.drawLoadView(true, -this.trYBottom / this.refreshConfigurator.getMaxTranslate()); + } + // 如果有上拉中动画回调,就执行上拉中动画回调 + if (this.onAnimPullUp) { + this.onAnimPullUp(-this.trYBottom / this.refreshConfigurator.getMaxTranslate(), this.mWidthNumber, -this.trYBottom); + } } } this.listOffsetOld = this.listOffsetNew; diff --git a/README.md b/README.md index 974ad27..96c6850 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ customRefresh: null, 在下述版本验证通过: -DevEco Studio: 3.1Beta2(3.1.0.400), SDK: API9 Release(3.2.11.9) +DevEco Studio: 4.0 Canary2(4.0.0.212), SDK: API10 (4.0.8.2) ## 贡献代码 diff --git a/build-profile.json5 b/build-profile.json5 index 5f240c9..db9704c 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -1,12 +1,20 @@ { "app": { - "signingConfigs": [], - "compileSdkVersion": 9, - "compatibleSdkVersion": 9, "products": [ { "name": "default", "signingConfig": "default", + "compileSdkVersion": "4.0.0(10)", + "compatibleSdkVersion": "4.0.0(10)", + "runtimeOS": "HarmonyOS" + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "release" } ] }, diff --git a/changelog.md b/changelog.md index 5f2cd1f..3cf277c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +## 2.0.3 + +1.修复组件在低版本镜像出现下拉刷新闪退问题。 +2.适配DevEco Studio: 4.0 Canary2(4.0.0.212) + 适配SDK: API10 (4.0.8.2) + ## 2.0.2 1.修复在轻微上拉的过程中,可能会出现直接滑动到底部的问题。 diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 index 64f8cb9..dd4ab4e 100644 --- a/entry/oh-package.json5 +++ b/entry/oh-package.json5 @@ -4,7 +4,7 @@ "name": "entry", "description": "example description", "repository": {}, - "version": "1.0.0", + "version": "2.0.3", "dependencies": { "@ohos/pulltorefresh": "file:../PullToRefresh" } diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 index 5d9bed6..c1f4e84 100644 --- a/hvigor/hvigor-config.json5 +++ b/hvigor/hvigor-config.json5 @@ -1,6 +1,6 @@ { - "hvigorVersion": "2.0.0", + "hvigorVersion": "2.2.0-rc.17.s", "dependencies": { - "@ohos/hvigor-ohos-plugin": "2.0.0" + "@ohos/hvigor-ohos-plugin": "2.2.0-rc.17.s" } } \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 index d7993a3..c2a9996 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -6,6 +6,6 @@ "name": "pulltorefresh", "description": "example description", "repository": {}, - "version": "1.0.0", + "version": "2.0.3", "dependencies": {} } -- Gitee