Skip to content

Does not work consistently with cloned nodes #33

@udyux

Description

@udyux

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)) { //...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions