You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-intersection-observer

Package Overview
Dependencies
Maintainers
1
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-intersection-observer - npm Package Compare versions

Comparing version

to
0.3.1

24

lib/intersection.js

@@ -42,8 +42,9 @@ "use strict";

if (!element) return;
var instance = INSTANCE_MAP.get(element);
if (instance) {
INSTANCE_MAP.delete(element);
if (INSTANCE_MAP.has(element)) {
var _INSTANCE_MAP$get = INSTANCE_MAP.get(element),
threshold = _INSTANCE_MAP$get.threshold;
var observerInstance = OBSERVER_MAP.get(instance.threshold);
var observerInstance = OBSERVER_MAP.get(threshold);
if (observerInstance) {

@@ -56,3 +57,3 @@ observerInstance.unobserve(element);

INSTANCE_MAP.forEach(function (item) {
if (item.threshold === instance.threshold) {
if (item.threshold === threshold) {
itemsLeft = true;

@@ -65,4 +66,7 @@ }

observerInstance.disconnect();
OBSERVER_MAP.delete(instance.threshold);
OBSERVER_MAP.delete(threshold);
}
// Remove reference to element
INSTANCE_MAP.delete(element);
}

@@ -78,6 +82,6 @@ }

var _INSTANCE_MAP$get = INSTANCE_MAP.get(target),
callback = _INSTANCE_MAP$get.callback,
visible = _INSTANCE_MAP$get.visible,
threshold = _INSTANCE_MAP$get.threshold;
var _INSTANCE_MAP$get2 = INSTANCE_MAP.get(target),
callback = _INSTANCE_MAP$get2.callback,
visible = _INSTANCE_MAP$get2.visible,
threshold = _INSTANCE_MAP$get2.threshold;

@@ -84,0 +88,0 @@ // Trigger on 0 ratio only when not visible. This is fallback for browsers without isIntersecting support

{
"name": "react-intersection-observer",
"version": "0.3.0",
"version": "0.3.1",
"description": "Monitor if a component is inside the viewport, using IntersectionObserver API",

@@ -68,3 +68,3 @@ "main": "lib/index.js",

"babel-jest": "^20.0.3",
"babel-plugin-transform-es2015-modules-commonjs": "6.24.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.1",
"babel-preset-react-app": "^3.0.0",

@@ -77,5 +77,6 @@ "babel-runtime": "6.23.0",

"eslint-config-prettier": "^2.1.1",
"husky": "^0.13.3",
"husky": "^0.13.4",
"intersection-observer": "^0.2.1",
"jest": "^20.0.4",
"lint-staged": "^3.5.0",
"lint-staged": "^3.5.1",
"prettier": "^1.3.1",

@@ -82,0 +83,0 @@ "prop-types": "^15.5.10",

@@ -37,3 +37,3 @@ # react-intersection-observer

### Polyfill for intersection-observer
The component requires the [intersection-observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) to be available on the global namespace. At the moment it is included in Chrome, Firefox, Opera and Edge. Make sure to include the polyfill to support other browsers like IE and Webkit.
The component requires the [intersection-observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) to be available on the global namespace. At the moment you should include a polyfill to ensure support in all browsers.

@@ -40,0 +40,0 @@ You can import the [polyfill](https://yarnpkg.com/en/package/intersection-observer) directly or use a service like [polyfill.io](https://polyfill.io/v2/docs/) that can add it when needed.

@@ -33,8 +33,7 @@ const INSTANCE_MAP = new Map()

if (!element) return
const instance = INSTANCE_MAP.get(element)
if (instance) {
INSTANCE_MAP.delete(element)
if (INSTANCE_MAP.has(element)) {
const { threshold } = INSTANCE_MAP.get(element)
const observerInstance = OBSERVER_MAP.get(threshold)
const observerInstance = OBSERVER_MAP.get(instance.threshold)
if (observerInstance) {

@@ -47,3 +46,3 @@ observerInstance.unobserve(element)

INSTANCE_MAP.forEach(item => {
if (item.threshold === instance.threshold) {
if (item.threshold === threshold) {
itemsLeft = true

@@ -56,4 +55,7 @@ }

observerInstance.disconnect()
OBSERVER_MAP.delete(instance.threshold)
OBSERVER_MAP.delete(threshold)
}
// Remove reference to element
INSTANCE_MAP.delete(element)
}

@@ -60,0 +62,0 @@ }