From fe5aae751504109b42b01b11c934cfd24b18a69f Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 5 Aug 2018 17:57:05 +0800 Subject: [PATCH] [Improvement] List: add check method (#1590) --- packages/list/en-US.md | 8 ++++++++ packages/list/index.vue | 10 +++++----- packages/list/zh-CN.md | 8 ++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/list/en-US.md b/packages/list/en-US.md index bab76a33f..ba0bc5b7c 100644 --- a/packages/list/en-US.md +++ b/packages/list/en-US.md @@ -64,3 +64,11 @@ export default { | Event | Description | Arguments | |-----------|-----------|-----------| | load | Triggered when the distance between the scrollbar and the bottom is less than offset | - | + +### Methods + +Use ref to get list instance and call instance methods + +| Name | Attribute | Return value | Description | +|-----------|-----------|-----------|-------------| +| check | - | - | Check scroll position | diff --git a/packages/list/index.vue b/packages/list/index.vue index 74dfb0272..03384132e 100644 --- a/packages/list/index.vue +++ b/packages/list/index.vue @@ -41,7 +41,7 @@ export default create({ this.handler(true); if (this.immediateCheck) { - this.$nextTick(this.onScroll); + this.$nextTick(this.check); } }, @@ -59,16 +59,16 @@ export default create({ watch: { loading() { - this.$nextTick(this.onScroll); + this.$nextTick(this.check); }, finished() { - this.$nextTick(this.onScroll); + this.$nextTick(this.check); } }, methods: { - onScroll() { + check() { if (this.loading || this.finished) { return; } @@ -109,7 +109,7 @@ export default create({ /* istanbul ignore else */ if (this.binded !== bind) { this.binded = bind; - (bind ? on : off)(this.scroller, 'scroll', this.onScroll); + (bind ? on : off)(this.scroller, 'scroll', this.check); } } } diff --git a/packages/list/zh-CN.md b/packages/list/zh-CN.md index 6e377ecb2..acd79b09c 100644 --- a/packages/list/zh-CN.md +++ b/packages/list/zh-CN.md @@ -64,3 +64,11 @@ export default { | 事件名 | 说明 | 参数 | |-----------|-----------|-----------| | load | 滚动条与底部距离小于 offset 时触发 | - | + +### 方法 + +通过 ref 可以获取到 list 实例并调用实例方法 + +| 方法名 | 参数 | 返回值 | 介绍 | +|-----------|-----------|-----------|-------------| +| check | - | - | 检查当前的滚动位置,若已滚动至底部,则会触发 load 事件 |