0
0
Fork 0

Fix infinite scroll in VnPaginate

This commit is contained in:
Kevin Martinez 2024-02-26 09:52:56 -03:00
parent 022ef24289
commit 698a88e6f0
1 changed files with 11 additions and 5 deletions

View File

@ -44,7 +44,7 @@ const props = defineProps({
},
offset: {
type: Number,
default: 500,
default: 0,
},
skeleton: {
type: Boolean,
@ -54,6 +54,10 @@ const props = defineProps({
type: Function,
default: null,
},
disableInfiniteScroll: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(['onFetch', 'onPaginate']);
@ -122,10 +126,11 @@ async function paginate() {
emit('onPaginate');
}
async function onLoad(...params) {
if (!store.data) return;
async function onLoad(index, done) {
if (!store.data) {
return done();
}
const done = params[1];
if (store.data.length === 0 || !props.url) return done(false);
pagination.value.page = pagination.value.page + 1;
@ -174,7 +179,8 @@ async function onLoad(...params) {
v-if="store.data"
@load="onLoad"
:offset="offset"
class="full-width full-height"
:disable="disableInfiniteScroll || !arrayData.hasMoreData.value"
class="full-width"
>
<slot name="body" :rows="store.data"></slot>
<div v-if="isLoading" class="info-row q-pa-md text-center">