Skip to content

Proper way of implementing infinite scroll without adding parameters to URL? #2174

Answered by AtteR
AtteR asked this question in Help (Vue)
Discussion options

You must be logged in to vote

Found a solution:

This to your Vue component script:

const currentPage = ref<number>(1);

Then in Vue:

            <WhenVisible
                :key="currentPage"
                :params="{
                    data: { page: currentPage + 1 },
                    only: ['projects'],
                    preserveUrl: true,
                    onSuccess: () => {
                        currentPage += 1;
                    }
                }"
            >
            </WhenVisible>

Some info:
:key is must, because otherwise only two pages are loaded on bigger screen sizes, giving :key, all the pages all loaded in bigger screen sizes.
preserveUrl:true makes it so that the URL is not appended …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by AtteR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant