diff --git a/blog.js b/blog.js index f96b6b5..6023185 100644 --- a/blog.js +++ b/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.