Add variable for scrolling posts into view
This commit is contained in:
parent
00357f444c
commit
32161bea62
12
blog.js
12
blog.js
@ -16,6 +16,16 @@ const postsContainerSelector = '#blog-posts';
|
||||
*/
|
||||
const viewMoreButtonSelector = '#view-more';
|
||||
|
||||
/**
|
||||
* When clicking "View more" to retrieve posts on page 2 and beyond
|
||||
* set this to `true` to scroll to the first post of the new batch of posts.
|
||||
*
|
||||
* If you do not want this behavior, set this to `false`.
|
||||
*
|
||||
* By default this is `true`.
|
||||
*/
|
||||
const scrollToPosts = true;
|
||||
|
||||
/**
|
||||
* Classes to add to the post's parent div.
|
||||
* By default these are Tailwind CSS classes: https://tailwindcss.com/
|
||||
@ -136,7 +146,7 @@ async function getPosts()
|
||||
* Style points only
|
||||
* Only trigger this logic after the "view more" button has been pressed
|
||||
*/
|
||||
if (nextPage > 1) {
|
||||
if (nextPage > 1 && scrollToPosts) {
|
||||
/**
|
||||
* Style points only
|
||||
* Scroll to the first post we got from the API.
|
||||
|
Loading…
Reference in New Issue
Block a user