vue-intersect icon indicating copy to clipboard operation
vue-intersect copied to clipboard

Does not work consistently with cloned nodes

Open udyux opened this issue 1 year ago • 0 comments

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

udyux avatar Mar 15 '23 16:03 udyux