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

Adding is intersecting check skips over initial load calls on full page infinite scroll #2

Open
GrizzlyEnglish opened this issue Apr 10, 2021 · 2 comments

Comments

@GrizzlyEnglish
Copy link

Not sure if this is still active, but by adding a check if the component is intersecting, stops the initial calls on render if the infinite scroll is a full page.

@GrizzlyEnglish
Copy link
Author

@SveNord This might be heavily specific to my issue with trying to utilize this for a school project. When I added this to a full page infinite scroll of postings, it pulled down the first 4 pages of content due to the component trigger being visible on initial render - so in order to fix that, I added

window.Observer = {
    observer: null,
    Initialize: function (component, observerTargetId) {
        this.observer = new IntersectionObserver(e => {
            // Check here
            if (e[0].isIntersecting) {
                component.invokeMethodAsync('OnIntersection');
            }
        });

        let element = document.getElementById(observerTargetId);
        if (element == null) throw new Error("The observable target was not found");
        this.observer.observe(element);
    }
};

Since this is a school project I did not test this outside my specific use case; but wanted to share!

@djflan
Copy link

djflan commented Aug 22, 2022

window.Observer = {
observer: null,
Initialize: function (component, observerTargetId) {
this.observer = new IntersectionObserver(e => {
// Check here
if (e[0].isIntersecting) {
component.invokeMethodAsync('OnIntersection');
}
});

    let element = document.getElementById(observerTargetId);
    if (element == null) throw new Error("The observable target was not found");
    this.observer.observe(element);
}

};

Experienced the same issue. Your code fixed it, thanks

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

No branches or pull requests

2 participants