Skip to content

Commit 6db798e

Browse files
committed
feat: add identifier prop to deprecate reset event
1 parent 1a2fdc1 commit 6db798e

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/components/InfiniteLoading.vue

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export default {
6363
type: Number,
6464
default: config.props.distance,
6565
},
66-
onInfinite: Function,
6766
spinner: {
6867
type: String,
6968
default: config.props.spinner,
@@ -76,6 +75,18 @@ export default {
7675
type: [Boolean, String],
7776
default: config.props.forceUseInfiniteWrapper,
7877
},
78+
identifier: {
79+
default: +new Date(),
80+
},
81+
onInfinite: Function,
82+
},
83+
watch: {
84+
forceUseInfiniteWrapper() {
85+
this.scrollParent = this.getScrollParent();
86+
},
87+
identifier() {
88+
this.stateChanger.reset();
89+
},
7990
},
8091
mounted() {
8192
this.scrollParent = this.getScrollParent();
@@ -127,13 +138,17 @@ export default {
127138
}
128139
});
129140
130-
this.$on('$InfiniteLoading:reset', () => {
141+
this.$on('$InfiniteLoading:reset', (ev) => {
131142
this.isLoading = false;
132143
this.isComplete = false;
133144
this.isFirstLoad = true;
134145
this.inThrottle = false;
135146
this.scrollParent.addEventListener('scroll', this.scrollHandler, evt3rdArg);
136147
setTimeout(this.scrollHandler, 1);
148+
149+
if (!ev || ev.target !== this) {
150+
console.warn(WARNINGS.IDENTIFIER);
151+
}
137152
});
138153
139154
if (this.onInfinite) {
@@ -154,13 +169,6 @@ export default {
154169
this.$emit('$InfiniteLoading:reset', { target: this });
155170
},
156171
};
157-
158-
/**
159-
* watch for the `force-use-infinite-wrapper` property
160-
*/
161-
this.$watch('forceUseInfiniteWrapper', () => {
162-
this.scrollParent = this.getScrollParent();
163-
});
164172
},
165173
/**
166174
* To adapt to keep-alive feature, but only work on Vue 2.2.0 and above, see: https://vuejs.org/v2/api/#keep-alive

src/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ infiniteHandler($state) {
8686
'more details: https://github.com/PeachScript/vue-infinite-loading/issues/57#issuecomment-324370549',
8787
].join('\n'),
8888
INFINITE_EVENT: '[Vue-infinite-loading warn]: `:on-infinite` property will be deprecated soon, please use `@infinite` event instead.',
89+
IDENTIFIER: '[Vue-infinite-loading warn]: the `reset` event will be deprecated soon, please reset this component by change the `identifier` property.',
8990
};
9091

9192
/**

0 commit comments

Comments
 (0)