diff --git a/src/pull-refresh/README.md b/src/pull-refresh/README.md index 2ad19434d..b88b98764 100644 --- a/src/pull-refresh/README.md +++ b/src/pull-refresh/README.md @@ -105,6 +105,7 @@ Use slots to custom tips. | success-duration | Success text display duration(ms) | _number \| string_ | `500` | | animation-duration | Animation duration | _number \| string_ | `300` | | head-height | Height of head | _number \| string_ | `50` | +| pull-distance `v2.12.8` | The distance to trigger the pull refresh | _number \| string_ | same as `head-height` | | disabled | Whether to disable pull refresh | _boolean_ | `false` | ### Events diff --git a/src/pull-refresh/README.zh-CN.md b/src/pull-refresh/README.zh-CN.md index 09979380e..37feec679 100644 --- a/src/pull-refresh/README.zh-CN.md +++ b/src/pull-refresh/README.zh-CN.md @@ -112,6 +112,7 @@ export default { | success-duration | 刷新成功提示展示时长(ms) | _number \| string_ | `500` | | animation-duration | 动画时长 | _number \| string_ | `300` | | head-height | 顶部内容高度 | _number \| string_ | `50` | +| pull-distance `v2.12.8` | 触发下拉刷新的距离 | _number \| string_ | 与 `head-height` 一致 | | disabled | 是否禁用下拉刷新 | _boolean_ | `false` | ### Events diff --git a/src/pull-refresh/index.js b/src/pull-refresh/index.js index 776017e71..86a1173b9 100644 --- a/src/pull-refresh/index.js +++ b/src/pull-refresh/index.js @@ -23,6 +23,7 @@ export default createComponent({ pullingText: String, loosingText: String, loadingText: String, + pullDistance: [Number, String], value: { type: Boolean, required: true, @@ -136,13 +137,13 @@ export default createComponent({ }, ease(distance) { - const headHeight = +this.headHeight; + const pullDistance = +(this.pullDistance || this.headHeight); - if (distance > headHeight) { - if (distance < headHeight * 2) { - distance = headHeight + (distance - headHeight) / 2; + if (distance > pullDistance) { + if (distance < pullDistance * 2) { + distance = pullDistance + (distance - pullDistance) / 2; } else { - distance = headHeight * 1.5 + (distance - headHeight * 2) / 4; + distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4; } } @@ -156,7 +157,10 @@ export default createComponent({ } else if (distance === 0) { status = 'normal'; } else { - status = distance < this.headHeight ? 'pulling' : 'loosing'; + status = + distance < (this.pullDistance || this.headHeight) + ? 'pulling' + : 'loosing'; } this.distance = distance;