Skip to content

.observe() bug fix, unbindAfterIntersect setting added#2

Open
aladage wants to merge 11 commits into
mainfrom
observe-fix
Open

.observe() bug fix, unbindAfterIntersect setting added#2
aladage wants to merge 11 commits into
mainfrom
observe-fix

Conversation

@aladage
Copy link
Copy Markdown
Contributor

@aladage aladage commented Nov 21, 2018

  • Fixed an issue that would prevent the .observe(els) method from working if there were no observable elements found during instantiation.
  • Added an "unbindAfterIntersect: [bool]" setting. It still defaults to true, but can be overridden now (useful when using the "onIntersectionCallback" setting).

Comment thread src/lazy.js
const observe = els => {
const onNonIntersection = el => {
if (settings.onNonIntersectionCallback !== null &&
initialIntersection === false) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the element is within the viewport at page load, and then the user scrolls down the page and the element leaves the viewport? You'd probably want the non-intersection callback to fire in that scenario, but I don't think it would because initialIntersection would be true.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also setting initialIntersection to false in your load() method would solve this problem?

Base automatically changed from master to main January 26, 2021 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants