Skip to content

Commit

Permalink
fix(uicomponenthelper): unregister observer even after the first posi…
Browse files Browse the repository at this point in the history
…tion calculation
  • Loading branch information
Jan Kučera committed Oct 12, 2018
1 parent 8c9569b commit edb88f9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/UIComponentHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export default class UIComponentHelper {
return function readVisibility() {
if (!isFirstPositionCalculated) {
isFirstPositionCalculated = true;
return self._getReader(element, options)();
return { visibility: self._getReader(element, options)(), observer };
}

return { intersectionObserverEntry, observer };
Expand Down Expand Up @@ -281,6 +281,12 @@ export default class UIComponentHelper {
!isIntersectionBugged ? entry.intersectionRatio * 100 : 100,
observer
);
} else if (
typeof payload === 'object' &&
payload.observer &&
payload.visibility
) {
return writer(payload.visibility, payload.observer);
} else {
return writer(payload);
}
Expand Down

0 comments on commit edb88f9

Please sign in to comment.