From baeb8cae56aa27a6758c32ed3556f5a59417b86b Mon Sep 17 00:00:00 2001 From: novlan1 <1576271227@qq.com> Date: Fri, 11 Jul 2025 17:40:57 +0800 Subject: [PATCH 1/5] perf: use simple tips-height to perf pull-down-refresh --- src/pull-down-refresh/pull-down-refresh.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pull-down-refresh/pull-down-refresh.ts b/src/pull-down-refresh/pull-down-refresh.ts index b262b29b4..078204c14 100644 --- a/src/pull-down-refresh/pull-down-refresh.ts +++ b/src/pull-down-refresh/pull-down-refresh.ts @@ -65,6 +65,7 @@ export default class PullDownRefresh extends SuperComponent { this.setData({ _maxBarHeight: unitConvert(maxBarHeight), _loadingBarHeight: unitConvert(loadingBarHeight), + tipsHeight: unitConvert(loadingBarHeight), loadingTexts: isCustomLoadingTexts ? loadingTexts : defaultLoadingTexts, }); @@ -105,8 +106,6 @@ export default class PullDownRefresh extends SuperComponent { this.setData({ refreshStatus: -1 }); }, 240); } - - this.setData({ tipsHeight: Math.min(val, this.data._loadingBarHeight) }); }, maxBarHeight(v) { @@ -114,7 +113,7 @@ export default class PullDownRefresh extends SuperComponent { }, loadingBarHeight(v) { - this.setData({ _loadingBarHeight: unitConvert(v) }); + this.setData({ tipsHeight: unitConvert(v), _loadingBarHeight: unitConvert(v) }); }, }; From e6a744b6874d4a60639e4c9e6ae5803916ba15d4 Mon Sep 17 00:00:00 2001 From: novlan1 <1576271227@qq.com> Date: Fri, 11 Jul 2025 18:05:38 +0800 Subject: [PATCH 2/5] feat(pull-down-refresh): add success-duration to prevent short success showing time --- src/pull-down-refresh/README.en-US.md | 1 + src/pull-down-refresh/README.md | 3 ++- src/pull-down-refresh/props.ts | 5 +++++ src/pull-down-refresh/pull-down-refresh.ts | 4 +++- src/pull-down-refresh/type.ts | 8 ++++++++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/pull-down-refresh/README.en-US.md b/src/pull-down-refresh/README.en-US.md index 891acfb2e..4aa46de01 100644 --- a/src/pull-down-refresh/README.en-US.md +++ b/src/pull-down-refresh/README.en-US.md @@ -20,6 +20,7 @@ max-bar-height | String / Number | 80 | \- | N refresh-timeout | Number | 3000 | \- | N scroll-into-view | String | - | `1.1.5` | N show-scrollbar | Boolean | true | \- | N +success-duration | String / Number | 500 | \- | N upper-threshold | String / Number | 50 | `1.1.5` | N using-custom-navbar | Boolean | false | \- | N value | Boolean | false | \- | N diff --git a/src/pull-down-refresh/README.md b/src/pull-down-refresh/README.md index b77784632..b053c78af 100644 --- a/src/pull-down-refresh/README.md +++ b/src/pull-down-refresh/README.md @@ -44,7 +44,7 @@ custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场 disabled | Boolean | false | 是否禁用下拉刷新 | N enable-back-to-top | Boolean | true | `1.1.5`。iOS点击顶部状态栏、安卓双击标题栏时,滚动条返回顶部,只支持竖向。自 2.27.3 版本开始,若非显式设置为 false,则在显示尺寸大于屏幕 90% 时自动开启 | N enable-passive | Boolean | false | `1.1.5`。开启 passive 特性,能优化一定的滚动性能 | N -header | Slot | - | `1.2.10`。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N +header | Slot | - | `1.2.10`。头部。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N loading-bar-height | String / Number | 50 | 加载中下拉高度,如果值为数字则单位是:'px' | N loading-props | Object | - | 加载loading样式。TS 类型:`LoadingProps`,[Loading API Documents](./loading?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/pull-down-refresh/type.ts) | N loading-texts | Array | [] | 提示语,组件内部默认值为 ['下拉刷新', '松手刷新', '正在刷新', '刷新完成']。TS 类型:`string[]` | N @@ -53,6 +53,7 @@ max-bar-height | String / Number | 80 | 最大下拉高度,如果值为数字 refresh-timeout | Number | 3000 | 刷新超时时间 | N scroll-into-view | String | - | `1.1.5`。值应为某子元素id(id不能以数字开头)。设置哪个方向可滚动,则在哪个方向滚动到该元素 | N show-scrollbar | Boolean | true | 滚动条显隐控制 (同时开启 enhanced 属性后生效) | N +success-duration | String / Number | 500 | 刷新成功提示展示时长,单位 'ms' | N upper-threshold | String / Number | 50 | `1.1.5`。距顶部/左边多远时,触发 scrolltoupper 事件 | N using-custom-navbar | Boolean | false | 是否使用了自定义导航栏 | N value | Boolean | false | 组件状态,值为 `true` 表示下拉状态,值为 `false` 表示收起状态 | N diff --git a/src/pull-down-refresh/props.ts b/src/pull-down-refresh/props.ts index f047e960b..6d93093ec 100644 --- a/src/pull-down-refresh/props.ts +++ b/src/pull-down-refresh/props.ts @@ -64,6 +64,11 @@ const props: TdPullDownRefreshProps = { type: Boolean, value: true, }, + /** 刷新成功提示展示时长,单位 'ms' */ + successDuration: { + type: null, + value: 500, + }, /** 距顶部/左边多远时,触发 scrolltoupper 事件 */ upperThreshold: { type: null, diff --git a/src/pull-down-refresh/pull-down-refresh.ts b/src/pull-down-refresh/pull-down-refresh.ts index 078204c14..318762b7a 100644 --- a/src/pull-down-refresh/pull-down-refresh.ts +++ b/src/pull-down-refresh/pull-down-refresh.ts @@ -93,8 +93,10 @@ export default class PullDownRefresh extends SuperComponent { this.setData({ refreshStatus: 3, }); + setTimeout(() => { + this.setData({ barHeight: 0 }); + }, this.properties.successDuration); } - this.setData({ barHeight: 0 }); } else { this.doRefresh(); } diff --git a/src/pull-down-refresh/type.ts b/src/pull-down-refresh/type.ts index 68f9bcd18..e001cec37 100644 --- a/src/pull-down-refresh/type.ts +++ b/src/pull-down-refresh/type.ts @@ -101,6 +101,14 @@ export interface TdPullDownRefreshProps { type: BooleanConstructor; value?: boolean; }; + /** + * 刷新成功提示展示时长,单位 'ms' + * @default 500 + */ + successDuration?: { + type: null; + value?: string | number; + }; /** * 距顶部/左边多远时,触发 scrolltoupper 事件 * @default 50 From 41e2cd4cb5f9c6c58fd08d60fb2348d63955aa8d Mon Sep 17 00:00:00 2001 From: novlan1 <1576271227@qq.com> Date: Fri, 11 Jul 2025 18:14:42 +0800 Subject: [PATCH 3/5] feat(pull-down-refresh): add uni-convert for success-duration --- src/pull-down-refresh/pull-down-refresh.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pull-down-refresh/pull-down-refresh.ts b/src/pull-down-refresh/pull-down-refresh.ts index 318762b7a..0cc77bb73 100644 --- a/src/pull-down-refresh/pull-down-refresh.ts +++ b/src/pull-down-refresh/pull-down-refresh.ts @@ -95,7 +95,7 @@ export default class PullDownRefresh extends SuperComponent { }); setTimeout(() => { this.setData({ barHeight: 0 }); - }, this.properties.successDuration); + }, unitConvert(this.properties.successDuration)); } } else { this.doRefresh(); From 8dfb4e23b895bd5945e9e94eac5dd53d0d1733ff Mon Sep 17 00:00:00 2001 From: novlan1 <1576271227@qq.com> Date: Fri, 11 Jul 2025 18:21:13 +0800 Subject: [PATCH 4/5] chore: update pull-down-refresh demo --- src/pull-down-refresh/_example/base/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pull-down-refresh/_example/base/index.js b/src/pull-down-refresh/_example/base/index.js index e4ad36efe..94524d968 100644 --- a/src/pull-down-refresh/_example/base/index.js +++ b/src/pull-down-refresh/_example/base/index.js @@ -22,6 +22,8 @@ Component({ }, onScroll(e) { const { scrollTop } = e.detail; + if (this.data.enable) return; + this.setData({ scrollTop }); }, }, From f363cefff7244f1e1446d5102168c369b9efe36f Mon Sep 17 00:00:00 2001 From: novlan1 <1576271227@qq.com> Date: Thu, 17 Jul 2025 21:32:11 +0800 Subject: [PATCH 5/5] fix(pull-down-refresh): fix issue where small movement distances on Android fail to trigger touchend --- src/pull-down-refresh/pull-down-refresh.wxml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pull-down-refresh/pull-down-refresh.wxml b/src/pull-down-refresh/pull-down-refresh.wxml index a69012f0a..c7638c1d8 100644 --- a/src/pull-down-refresh/pull-down-refresh.wxml +++ b/src/pull-down-refresh/pull-down-refresh.wxml @@ -18,6 +18,7 @@ bind:touchstart="onTouchStart" bind:touchmove="onTouchMove" bind:touchend="onTouchEnd" + bind:touchcancel="onTouchEnd" bind:scroll="onScroll" binddragstart="onDragStart" binddragging="onDragging"