fix: infinite scroll bug on all recipes page (#1393)

This commit is contained in:
Michael Genson 2022-06-15 15:56:56 -05:00 committed by GitHub
parent 3f808f8f00
commit 9e261f5235
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,7 @@
</v-fade-transition> </v-fade-transition>
</v-container> </v-container>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, onMounted, ref } from "@nuxtjs/composition-api"; import { defineComponent, onMounted, ref } from "@nuxtjs/composition-api";
import { useThrottleFn } from "@vueuse/core"; import { useThrottleFn } from "@vueuse/core";
@ -23,8 +23,9 @@ export default defineComponent({
components: { RecipeCardSection }, components: { RecipeCardSection },
setup() { setup() {
const start = ref(0); const start = ref(0);
const limit = ref(30);
const increment = ref(30); const increment = ref(30);
const offset = ref(increment.value);
const limit = ref(increment.value);
const ready = ref(false); const ready = ref(false);
const loading = ref(false); const loading = ref(false);
@ -40,8 +41,8 @@ export default defineComponent({
return; return;
} }
loading.value = true; loading.value = true;
start.value = limit.value + 1; start.value = offset.value + 1;
limit.value = limit.value + increment.value; offset.value = offset.value + increment.value;
fetchMore(start.value, limit.value); fetchMore(start.value, limit.value);
loading.value = false; loading.value = false;
}, 500); }, 500);
@ -64,4 +65,3 @@ export default defineComponent({
}, },
}); });
</script> </script>