oumoussa98 / vue3-infinite-loading

Infinite scroll component compatible with vuejs-3 and vitejs
https://vue3-infinite-loading.netlify.app/
191 stars 31 forks source link

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

Open johnsmith0209 opened 1 month ago

johnsmith0209 commented 1 month ago

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);
oumoussa98 commented 1 month ago

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;