Skip to content

Commit 78b8ee6

Browse files
committed
Improve example
1 parent bd9d92d commit 78b8ee6

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

example/index.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
border-top: 1px solid #fff;
2020
border-bottom: 1px solid #e3e3e3;
2121
}
22-
.example-list-item:before{
22+
.example-list-item::before{
2323
content: 'Line: ';
2424
}
2525
</style>
2626
</head>
2727
<body>
2828
<div id="app">
2929
<p class="example-list-item" v-for="item in list" v-text="item"></p>
30-
<infinite-loading :on-infinite="onInfinite" :distance="distance" v-if="list.length < 300"></infinite-loading>
30+
<infinite-loading :on-infinite="onInfinite" :distance="distance"></infinite-loading>
3131
</div>
3232
<script>
3333
new Vue({
@@ -38,15 +38,19 @@
3838
},
3939
methods: {
4040
onInfinite: function () {
41-
setTimeout(function () {
42-
var temp = [];
43-
for (var i = this.list.length; i <= this.list.length + 10; i++) {
44-
temp.push(i);
45-
}
41+
if (this.list.length > 200) {
42+
this.$broadcast('$InfiniteLoading:complete');
43+
} else {
44+
setTimeout(function () {
45+
var temp = [];
46+
for (var i = this.list.length; i <= this.list.length + 10; i++) {
47+
temp.push(i);
48+
}
4649

47-
this.list = this.list.concat(temp);
48-
this.$broadcast('$InfiniteLoading:loaded');
49-
}.bind(this), 1000);
50+
this.list = this.list.concat(temp);
51+
this.$broadcast('$InfiniteLoading:loaded');
52+
}.bind(this), 1000);
53+
}
5054
}
5155
}
5256
});

0 commit comments

Comments
 (0)