lozad.js icon indicating copy to clipboard operation
lozad.js copied to clipboard

Elements aren't Unobserved if Loaded via triggerLoad

Open TiKevin83 opened this issue 7 years ago • 2 comments

I noticed that the triggerLoad function currently does not unobserve elements, so an unnecessary onIntersection can still happen that will return immediately due to the isLoaded check. I had the idea in my fork to instead of just adding observer.unobserve(element) in triggerLoad to also have the onIntersection and observe methods call triggerLoad instead of duplicating the code from triggerLoad. Would this be a sane change?

https://github.com/TiKevin83/lozad.js/commit/97e02bed37d0185eaccad9883a4d09c57f9f9604

TiKevin83 avatar Sep 11 '18 21:09 TiKevin83

yes, it should unobserve element after it's loaded by any means

ApoorvSaxena avatar Oct 31 '18 06:10 ApoorvSaxena

Has this been incorporated into the main branch @ApoorvSaxena ? Thanks for the great plugin!

jesserosenfield avatar Apr 09 '20 16:04 jesserosenfield