react-intersection-observer
Advanced tools
Comparing version 0.2.8 to 0.2.9
@@ -57,8 +57,12 @@ 'use strict'; | ||
var itemsLeft = INSTANCE_MAP.values().some(function (item) { | ||
return item.threshold === instance.threshold; | ||
// Check if we are stilling observing any elements with the same threshold. | ||
var itemsLeft = false; | ||
INSTANCE_MAP.forEach(function (item) { | ||
if (item.threshold === instance.threshold) { | ||
itemsLeft = true; | ||
} | ||
}); | ||
if (observerInstance && !itemsLeft) { | ||
// No more elements to observe, disconnect | ||
// No more elements to observe for threshold, disconnect observer | ||
observerInstance.disconnect(); | ||
@@ -65,0 +69,0 @@ OBSERVER_MAP.delete(instance.threshold); |
{ | ||
"name": "react-intersection-observer", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"description": "Monitor if a component is inside the viewport, using IntersectionObserver API", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -48,8 +48,12 @@ if (global.window && !process.env.SERVER) { | ||
const itemsLeft = INSTANCE_MAP.values().some( | ||
item => item.threshold === instance.threshold, | ||
) | ||
// Check if we are stilling observing any elements with the same threshold. | ||
let itemsLeft = false | ||
INSTANCE_MAP.forEach(item => { | ||
if (item.threshold === instance.threshold) { | ||
itemsLeft = true | ||
} | ||
}) | ||
if (observerInstance && !itemsLeft) { | ||
// No more elements to observe, disconnect | ||
// No more elements to observe for threshold, disconnect observer | ||
observerInstance.disconnect() | ||
@@ -56,0 +60,0 @@ OBSERVER_MAP.delete(instance.threshold) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23545
384