ApoorvSaxena/lozad.js

Elements aren't Unobserved if Loaded via triggerLoad

Open

#129 opened on Sep 11, 2018

View on GitHub
 (2 comments) (1 reaction) (0 assignees)JavaScript (476 forks)batch import
Hacktoberfestenhancement

Repository metrics

Stars
 (7,370 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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

Contributor guide