vue3-infinite-loading icon indicating copy to clipboard operation
vue3-infinite-loading copied to clipboard

Why does the IntersectionObserver Callback only take care of the first entry?

Open johnsmith0209 opened this issue 1 year ago • 1 comments

I was caught on an issue: When the page was mounted, not every time the @infinite event was called.

After I added console.log to the IntersectionObserver callback, I found that the entries param was an array with 2 items.

image

But the code shows that only first item of entries is used. Why ? https://github.com/oumoussa98/vue3-infinite-loading/blob/089119fcfe75d18d406737707fcddd5adc49326a/src/utils.ts#L34

Shouldn't this code be like:

const entry = entries.at(-1);

johnsmith0209 avatar Sep 07 '24 16:09 johnsmith0209

The observer is intended to observe only one element, which is the infinite-loading component itself; so entries length shouldn't be more than 1 element; https://github.com/oumoussa98/vue3-infinite-loading/blob/089119fcfe75d18d406737707fcddd5adc49326a/src/utils.ts#L42

however, it could also be caused by this issue #78 that has been fixed in the latest version;

I recommend upgrading to the latest version (1.3.2); If the problem persists, please provide a repro so we can further investigate;

oumoussa98 avatar Sep 07 '24 19:09 oumoussa98