You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This doesn't work. Firstly, it doesn't remove the observer entry correctly, secondly, if the element is not found i.e. elements.indexOf(img) === -1, the splice removes the last element of the array! The result is that some images don't get loaded.
There's an easy fix, I'll put through a PR.
The text was updated successfully, but these errors were encountered:
I'm just seeing this now, as it must have gotten buried in my notifications. I've noticed this behavior myself, but didn't know exactly where it was failing. I'll test this out and accept your PR once I can verify the fix. Thank you so much, @anthonygore!
- Implementing @anthonygore's bugfix (#13) where the last image in a set would fail to load, due to my buggy IntersectionObserver code.
- Updated packages.
- Incremented version to 1.1.2.
- Updated the README.
FWIW, I did need to still track the number of elements in the array so that the lazy loading behavior could be unbound for users of browsers without Intersection Observer support. So I relied on the filter method to achieve this, which seems to be more reliable than splice.
This doesn't work. Firstly, it doesn't remove the observer entry correctly, secondly, if the element is not found i.e.
elements.indexOf(img) === -1
, the splice removes the last element of the array! The result is that some images don't get loaded.There's an easy fix, I'll put through a PR.
The text was updated successfully, but these errors were encountered: