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

Does not work consistently with cloned nodes #33

Open
udyux opened this issue Mar 15, 2023 · 0 comments
Open

Does not work consistently with cloned nodes #33

udyux opened this issue Mar 15, 2023 · 0 comments

Comments

@udyux
Copy link

udyux commented Mar 15, 2023

Its only a theory as it is a bit difficult to debug, bug when using packages such a simplebar, which will clone the HTML content into a structure it created, sometimes the observed node automatically becomes the second entry in the IntersectionObserver and the first one acts as if it were no longer in the DOM.

This isn't a bug created by vue-intersect but a behavior I've observed implementing IntersectionObservers manually as well.

The solution would be quite simple. At src/index.js:31 instead of assuming there is only one entry:

if (!entries[0].isIntersecting) { //...

Just check all entries, stopping on the first one that is true:

if (!entries.some(({ isIntersecting }) => isIntersecting)) { //...
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

1 participant