react-intersection-observer
Advanced tools
Comparing version 9.5.1 to 9.5.2
@@ -44,2 +44,3 @@ "use client"; | ||
entries.forEach((entry) => { | ||
var _a; | ||
const inView = entry.isIntersecting && thresholds.some((threshold) => entry.intersectionRatio >= threshold); | ||
@@ -49,3 +50,3 @@ if (options.trackVisibility && typeof entry.isVisible === "undefined") { | ||
} | ||
elements.get(entry.target)?.forEach((callback) => { | ||
(_a = elements.get(entry.target)) == null ? void 0 : _a.forEach((callback) => { | ||
callback(inView, entry); | ||
@@ -219,2 +220,3 @@ }); | ||
} = {}) { | ||
var _a; | ||
const [ref, setRef] = React2.useState(null); | ||
@@ -279,3 +281,3 @@ const callback = React2.useRef(); | ||
); | ||
const entryTarget = state.entry?.target; | ||
const entryTarget = (_a = state.entry) == null ? void 0 : _a.target; | ||
const previousEntryTarget = React2.useRef(); | ||
@@ -282,0 +284,0 @@ if (!ref && entryTarget && !triggerOnce && !skip && previousEntryTarget.current !== entryTarget) { |
57
index.js
@@ -9,2 +9,3 @@ "use strict"; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __export = (target, all) => { | ||
@@ -31,2 +32,6 @@ for (var name in all) | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
@@ -78,2 +83,3 @@ // src/index.tsx | ||
entries.forEach((entry) => { | ||
var _a; | ||
const inView = entry.isIntersecting && thresholds.some((threshold) => entry.intersectionRatio >= threshold); | ||
@@ -83,3 +89,3 @@ if (options.trackVisibility && typeof entry.isVisible === "undefined") { | ||
} | ||
elements.get(entry.target)?.forEach((callback) => { | ||
(_a = elements.get(entry.target)) == null ? void 0 : _a.forEach((callback) => { | ||
callback(inView, entry); | ||
@@ -141,2 +147,25 @@ }); | ||
super(props); | ||
__publicField(this, "node", null); | ||
__publicField(this, "_unobserveCb", null); | ||
__publicField(this, "handleNode", (node) => { | ||
if (this.node) { | ||
this.unobserve(); | ||
if (!node && !this.props.triggerOnce && !this.props.skip) { | ||
this.setState({ inView: !!this.props.initialInView, entry: void 0 }); | ||
} | ||
} | ||
this.node = node ? node : null; | ||
this.observeNode(); | ||
}); | ||
__publicField(this, "handleChange", (inView, entry) => { | ||
if (inView && this.props.triggerOnce) { | ||
this.unobserve(); | ||
} | ||
if (!isPlainChildren(this.props)) { | ||
this.setState({ inView, entry }); | ||
} | ||
if (this.props.onChange) { | ||
this.props.onChange(inView, entry); | ||
} | ||
}); | ||
this.state = { | ||
@@ -157,4 +186,2 @@ inView: !!props.initialInView, | ||
} | ||
node = null; | ||
_unobserveCb = null; | ||
observeNode() { | ||
@@ -192,23 +219,2 @@ if (!this.node || this.props.skip) | ||
} | ||
handleNode = (node) => { | ||
if (this.node) { | ||
this.unobserve(); | ||
if (!node && !this.props.triggerOnce && !this.props.skip) { | ||
this.setState({ inView: !!this.props.initialInView, entry: void 0 }); | ||
} | ||
} | ||
this.node = node ? node : null; | ||
this.observeNode(); | ||
}; | ||
handleChange = (inView, entry) => { | ||
if (inView && this.props.triggerOnce) { | ||
this.unobserve(); | ||
} | ||
if (!isPlainChildren(this.props)) { | ||
this.setState({ inView, entry }); | ||
} | ||
if (this.props.onChange) { | ||
this.props.onChange(inView, entry); | ||
} | ||
}; | ||
render() { | ||
@@ -256,2 +262,3 @@ const { children } = this.props; | ||
} = {}) { | ||
var _a; | ||
const [ref, setRef] = React2.useState(null); | ||
@@ -316,3 +323,3 @@ const callback = React2.useRef(); | ||
); | ||
const entryTarget = state.entry?.target; | ||
const entryTarget = (_a = state.entry) == null ? void 0 : _a.target; | ||
const previousEntryTarget = React2.useRef(); | ||
@@ -319,0 +326,0 @@ if (!ref && entryTarget && !triggerOnce && !skip && previousEntryTarget.current !== entryTarget) { |
{ | ||
"name": "react-intersection-observer", | ||
"version": "9.5.1", | ||
"version": "9.5.2", | ||
"description": "Monitor if a component is inside the viewport, using IntersectionObserver API", | ||
@@ -5,0 +5,0 @@ "source": "./src/index.tsx", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
133449
1290