Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load more with button, button not hidden #930

Closed
thewebartisan7 opened this issue Nov 3, 2020 · 1 comment
Closed

Load more with button, button not hidden #930

thewebartisan7 opened this issue Nov 3, 2020 · 1 comment

Comments

@thewebartisan7
Copy link

thewebartisan7 commented Nov 3, 2020

I see an example that button for load more is hidden or disabled during request and then again visible on load. I see also source code of this. But when I try to use it, then it's always visible, and not disabled or hidden. I try with option loadOnScroll and scrollThreshold. Infinitescroll works fine, the problem is that I want to hide button view more during request.

Here is part of my code, please let me know what is wrong:

            const grid = document.querySelector('.grid')

            const viewMoreButton = document.querySelector('.view-more-button')
            viewMoreButton.style.display = 'block'

            const infScroll = new InfiniteScroll(grid, {
                path: 'a[rel="next"]',
                append: '.item',
                button: viewMoreButton.querySelector('.js-load-more'),
                status: '.page-load-status',
                //loadOnScroll: false, // Same not working also
                scrollThreshold: false, // Try also this but same
            })

            infScroll.on('load', function(response) {
                // I do something here with response...
            })
@desandro
Copy link
Member

desandro commented Dec 5, 2020

You can hide on [request](https://infinite-scroll.com/events.html#request), then show on load

infScroll.on( 'request', function( path ) {
  viewMoreButton.style.display = 'none';
});

infScroll.on( 'load', function( path ) {
  viewMoreButton.style.display = 'block';
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants