[Improvement] List: add check method (#1590)

This commit is contained in:
neverland 2018-08-05 17:57:05 +08:00 committed by GitHub
parent 428cb5059a
commit fe5aae7515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 5 deletions

View File

@ -64,3 +64,11 @@ export default {
| Event | Description | Arguments | | Event | Description | Arguments |
|-----------|-----------|-----------| |-----------|-----------|-----------|
| load | Triggered when the distance between the scrollbar and the bottom is less than offset | - | | 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 |

View File

@ -41,7 +41,7 @@ export default create({
this.handler(true); this.handler(true);
if (this.immediateCheck) { if (this.immediateCheck) {
this.$nextTick(this.onScroll); this.$nextTick(this.check);
} }
}, },
@ -59,16 +59,16 @@ export default create({
watch: { watch: {
loading() { loading() {
this.$nextTick(this.onScroll); this.$nextTick(this.check);
}, },
finished() { finished() {
this.$nextTick(this.onScroll); this.$nextTick(this.check);
} }
}, },
methods: { methods: {
onScroll() { check() {
if (this.loading || this.finished) { if (this.loading || this.finished) {
return; return;
} }
@ -109,7 +109,7 @@ export default create({
/* istanbul ignore else */ /* istanbul ignore else */
if (this.binded !== bind) { if (this.binded !== bind) {
this.binded = bind; this.binded = bind;
(bind ? on : off)(this.scroller, 'scroll', this.onScroll); (bind ? on : off)(this.scroller, 'scroll', this.check);
} }
} }
} }

View File

@ -64,3 +64,11 @@ export default {
| 事件名 | 说明 | 参数 | | 事件名 | 说明 | 参数 |
|-----------|-----------|-----------| |-----------|-----------|-----------|
| load | 滚动条与底部距离小于 offset 时触发 | - | | load | 滚动条与底部距离小于 offset 时触发 | - |
### 方法
通过 ref 可以获取到 list 实例并调用实例方法
| 方法名 | 参数 | 返回值 | 介绍 |
|-----------|-----------|-----------|-------------|
| check | - | - | 检查当前的滚动位置,若已滚动至底部,则会触发 load 事件 |