You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For upward direction, `vue-loadmore` uses pull-to-refresh to load more. Pull the component `topDistance` pixels away from the top and then release it, the function you appointed as `top-method` will run:
49
+
For upward direction, pull the component `topDistance` pixels away from the top and then release it, the function you appointed as `top-method` will run:
46
50
```Javascript
47
51
loadTop() {
48
52
...// load more data
@@ -51,22 +55,23 @@ loadTop() {
51
55
```
52
56
At the end of your `top-method`, don't forget to broadcast the `onTopLoaded` event so that `vue-loadmore` removes `topLoadingText`.
53
57
54
-
For downward direction, you have two options:
55
-
* Set `bottom-need-pull` to `true`, then pull-to-refresh will be applied. In this case, to invoke `bottom-method`, just pull the component `bottomDistance` pixels away from the bottom and then release it.
56
-
* Set `bottom-need-pull` to `false` or simply omit it, `bottom-method` will run automatically when the bottom of the component is less than `bottomDistance` pixels away from the bottom of its container.
57
-
58
-
The [example](http://leopoldthecoder.github.io/Demos/vue-loadmore/index.html) demonstrates the difference between these two options.
59
-
58
+
For downward direction, things are similar. To invoke `bottom-method`, just pull the component `bottomDistance` pixels away from the bottom and then release it.
60
59
```Javascript
61
-
loadBottom() {
60
+
loadBottom(id) {
62
61
...// load more data
63
62
this.allLoaded=true;// if all data are loaded
64
-
this.$broadcast('onBottomLoaded');
63
+
this.$broadcast('onBottomLoaded', id);
65
64
}
66
65
```
67
-
Remember to set `bottom-all-loaded` to `true` after all data are loaded. And of course broadcast `onBottomLoaded`.
66
+
Remember to set `bottom-all-loaded` to `true` after all data are loaded. And of course broadcast `onBottomLoaded`. Note that a parameter called `id` is passed to `loadmore`. This is because after the bottom data is loaded, some reposition work is performed inside a `vue-loadmore` instance, and `id` simply tells the component which instance should be repositioned. You don't need to do anything more than passing `id` to `onBottomLoaded` just as shown above.
67
+
68
+
You can customize the top and bottom DOM using an HTML template. For example, to customize the top DOM, you'll need to add a variable that syncs with `top-status` on `loadmore` tag, and then write your template with a `slot` attribute set to `top` and `class` set to `kebab-loadmore-top`. `top-status` has three possible values that indicates which status the component is at:
69
+
*`pull` if the component is being pulled yet not ready to drop
70
+
*`drop` if the component is ready to drop
71
+
*`loading` if `topMethod` is running
72
+
And of course, if a top HTMl template is given, `topPullText`, `topDropText` and `topLoadingText` are all unnecessary.
68
73
69
-
If you don't need to load data from upward direction, simply omit the `topMethod` attribute. Same goes to downward.
74
+
Don't need to load data from upward direction? Simply omit the `topMethod` attribute. Same goes to downward.
70
75
71
76
# API
72
77
| Option | Description | Value | Default |
@@ -82,7 +87,6 @@ If you don't need to load data from upward direction, simply omit the `topMethod
82
87
| bottomDistance | distance threshold that triggers `bottomMethod`| Number | 70 |
83
88
| bottomMethod | downward load-more function | Function ||
84
89
| bottomAllLoaded | if `true`, `bottomMethod` can no longer be triggered | Boolean | false |
85
-
| bottomNeedPull | if `true`, pull-to-refresh will be applied on downward direction | Boolean | false |
0 commit comments