Skip to content

Commit ce1ff3a

Browse files
committed
Modify source code to adapt to Vue.js 2.0.x
1 parent be8b884 commit ce1ff3a

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/components/InfiniteLoading.vue

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,14 @@
6767
},
6868
},
6969
props: {
70-
distance: Number,
70+
distance: {
71+
type: Number,
72+
default: 100,
73+
},
7174
onInfinite: Function,
7275
spinner: String,
7376
},
74-
ready() {
75-
if (this.distance === undefined) {
76-
this.$set('distance', 100);
77-
}
78-
77+
mounted() {
7978
this.scrollParent = getScrollParent(this.$el);
8079
8180
this.scrollHandler = function scrollHandlerOriginal() {
@@ -90,24 +89,23 @@
9089
9190
setTimeout(this.scrollHandler, 1);
9291
this.scrollParent.addEventListener('scroll', this.scrollHandler);
93-
},
94-
events: {
95-
'$InfiniteLoading:loaded': function loaded() {
92+
93+
this.$on('$InfiniteLoading:loaded', () => {
9694
this.isLoading = false;
9795
this.isFirstLoad = false;
98-
},
99-
'$InfiniteLoading:complete': function complete() {
96+
});
97+
this.$on('$InfiniteLoading:complete', () => {
10098
this.isLoading = false;
10199
this.isComplete = true;
102100
this.scrollParent.removeEventListener('scroll', this.scrollHandler);
103-
},
104-
'$InfiniteLoading:reset': function reset() {
101+
});
102+
this.$on('$InfiniteLoading:reset', () => {
105103
this.isLoading = false;
106104
this.isComplete = false;
107105
this.isFirstLoad = true;
108106
this.scrollParent.addEventListener('scroll', this.scrollHandler);
109107
setTimeout(this.scrollHandler, 1);
110-
},
108+
});
111109
},
112110
destroyed() {
113111
if (!this.isComplete) {

0 commit comments

Comments
 (0)