Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

intersection-observer-admin

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intersection-observer-admin - npm Package Compare versions

Comparing version 0.2.12 to 0.2.13

.github/workflows/ci.yml

52

dist/es/index.js

@@ -27,3 +27,3 @@ var __extends = (this && this.__extends) || (function () {

*
* @method add
* @method observe
* @param {HTMLElement | Window} element

@@ -50,3 +50,3 @@ * @param {Object} options

IntersectionObserverAdmin.prototype.unobserve = function (target, options) {
var matchingRootEntry = this._findMatchingRootEntry(options);
var matchingRootEntry = this.findMatchingRootEntry(options);
if (matchingRootEntry) {

@@ -117,10 +117,10 @@ var intersectionObserver = matchingRootEntry.intersectionObserver;

var _b = options.root, root = _b === void 0 ? window : _b;
// find shared root element (window or target HTMLElement)
// First - find shared root element (window or target HTMLElement)
// this root is responsible for coordinating it's set of elements
var potentialRootMatch = this._findRoot(root);
// third if there is a matching root, see if an existing entry with the same options
// regardless of sort order. This is a bit of work
var potentialRootMatch = this.findRootFromRegistry(root);
// Second - if there is a matching root, see if an existing entry with the same options
// regardless of sort order. This is a bit of work
var matchingEntryForRoot;
if (potentialRootMatch) {
matchingEntryForRoot = this._determineMatchingElements(options, potentialRootMatch);
matchingEntryForRoot = this.determineMatchingElements(options, potentialRootMatch);
}

@@ -146,3 +146,3 @@ // next add found entry to elements and call observer if applicable

// with watcher so we can use it later on
var stringifiedOptions = this._stringifyOptions(options);
var stringifiedOptions = this.stringifyOptions(options);
if (potentialRootMatch) {

@@ -172,2 +172,4 @@ // if share same root and need to add new entry to root match

* configured `threshold`s.
* Exit callback occurs eagerly (when element is initially out of scope)
* See https://stackoverflow.com/questions/53214116/intersectionobserver-callback-firing-immediately-on-page-load/53385264#53385264
*

@@ -188,3 +190,3 @@ * @method onIntersection

// then find entry's callback in static administration
var matchingRootEntry = _this._findMatchingRootEntry(options);
var matchingRootEntry = _this.findMatchingRootEntry(options);
// first determine if entry intersecting

@@ -217,3 +219,3 @@ if (isIntersecting || intersectionRatio > threshold) {

* { root: { stringifiedOptions: { observer, elements: []...] } }
* @method _findRoot
* @method findRootFromRegistry
* @param {HTMLElement|Window} root

@@ -223,3 +225,3 @@ * @private

*/
IntersectionObserverAdmin.prototype._findRoot = function (root) {
IntersectionObserverAdmin.prototype.findRootFromRegistry = function (root) {
if (this.elementRegistry) {

@@ -233,11 +235,11 @@ return this.elementRegistry.getElement(root);

*
* @method _findMatchingRootEntry
* @method findMatchingRootEntry
* @param {Object} options
* @return {Object} entry with elements and other options
*/
IntersectionObserverAdmin.prototype._findMatchingRootEntry = function (options) {
IntersectionObserverAdmin.prototype.findMatchingRootEntry = function (options) {
var _a = options.root, root = _a === void 0 ? window : _a;
var matchingRoot = this._findRoot(root);
var matchingRoot = this.findRootFromRegistry(root);
if (matchingRoot) {
var stringifiedOptions = this._stringifyOptions(options);
var stringifiedOptions = this.stringifyOptions(options);
return matchingRoot[stringifiedOptions];

@@ -250,3 +252,3 @@ }

*
* @method _determineMatchingElements
* @method determineMatchingElements
* @param {Object} options

@@ -257,9 +259,9 @@ * @param {Object} potentialRootMatch e.g. { stringifiedOptions: { elements: [], ... }, stringifiedOptions: { elements: [], ... }}

*/
IntersectionObserverAdmin.prototype._determineMatchingElements = function (options, potentialRootMatch) {
IntersectionObserverAdmin.prototype.determineMatchingElements = function (options, potentialRootMatch) {
var _this = this;
var matchingKey = Object.keys(potentialRootMatch).filter(function (key) {
var matchingStringifiedOptions = Object.keys(potentialRootMatch).filter(function (key) {
var comparableOptions = potentialRootMatch[key].options;
return _this._areOptionsSame(options, comparableOptions);
return _this.areOptionsSame(options, comparableOptions);
})[0];
return potentialRootMatch[matchingKey];
return potentialRootMatch[matchingStringifiedOptions];
};

@@ -270,3 +272,3 @@ /**

*
* @method _areOptionsSame
* @method areOptionsSame
* @param {any} a

@@ -277,3 +279,3 @@ * @param {any} b

*/
IntersectionObserverAdmin.prototype._areOptionsSame = function (a, b) {
IntersectionObserverAdmin.prototype.areOptionsSame = function (a, b) {
if (a === b) {

@@ -294,5 +296,5 @@ return true;

for (var key in a) {
if (a.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(a, key)) {
// recursion to check nested
if (this._areOptionsSame(a[key], b[key]) === false) {
if (this.areOptionsSame(a[key], b[key]) === false) {
return false;

@@ -314,3 +316,3 @@ }

*/
IntersectionObserverAdmin.prototype._stringifyOptions = function (options) {
IntersectionObserverAdmin.prototype.stringifyOptions = function (options) {
var root = options.root;

@@ -317,0 +319,0 @@ var replacer = function (key, value) {

@@ -17,4 +17,4 @@ var Registry = /** @class */ (function () {

* @param {IOption} options
* @param {IOption.root} root - contains optional root e.g. window, container div, etc
* @param {IOption.watcher} observer - optional
* @param {IOption.root} [root] - contains optional root e.g. window, container div, etc
* @param {IOption.watcher} [observer] - optional
* @public

@@ -21,0 +21,0 @@ */

@@ -17,4 +17,4 @@ var Registry = /** @class */ (function () {

* @param {IOption} options
* @param {IOption.root} root - contains optional root e.g. window, container div, etc
* @param {IOption.watcher} observer - optional
* @param {IOption.root} [root] - contains optional root e.g. window, container div, etc
* @param {IOption.watcher} [observer] - optional
* @public

@@ -119,3 +119,3 @@ */

*
* @method add
* @method observe
* @param {HTMLElement | Window} element

@@ -142,3 +142,3 @@ * @param {Object} options

IntersectionObserverAdmin.prototype.unobserve = function (target, options) {
var matchingRootEntry = this._findMatchingRootEntry(options);
var matchingRootEntry = this.findMatchingRootEntry(options);
if (matchingRootEntry) {

@@ -209,10 +209,10 @@ var intersectionObserver = matchingRootEntry.intersectionObserver;

var _b = options.root, root = _b === void 0 ? window : _b;
// find shared root element (window or target HTMLElement)
// First - find shared root element (window or target HTMLElement)
// this root is responsible for coordinating it's set of elements
var potentialRootMatch = this._findRoot(root);
// third if there is a matching root, see if an existing entry with the same options
// regardless of sort order. This is a bit of work
var potentialRootMatch = this.findRootFromRegistry(root);
// Second - if there is a matching root, see if an existing entry with the same options
// regardless of sort order. This is a bit of work
var matchingEntryForRoot;
if (potentialRootMatch) {
matchingEntryForRoot = this._determineMatchingElements(options, potentialRootMatch);
matchingEntryForRoot = this.determineMatchingElements(options, potentialRootMatch);
}

@@ -238,3 +238,3 @@ // next add found entry to elements and call observer if applicable

// with watcher so we can use it later on
var stringifiedOptions = this._stringifyOptions(options);
var stringifiedOptions = this.stringifyOptions(options);
if (potentialRootMatch) {

@@ -264,2 +264,4 @@ // if share same root and need to add new entry to root match

* configured `threshold`s.
* Exit callback occurs eagerly (when element is initially out of scope)
* See https://stackoverflow.com/questions/53214116/intersectionobserver-callback-firing-immediately-on-page-load/53385264#53385264
*

@@ -280,3 +282,3 @@ * @method onIntersection

// then find entry's callback in static administration
var matchingRootEntry = _this._findMatchingRootEntry(options);
var matchingRootEntry = _this.findMatchingRootEntry(options);
// first determine if entry intersecting

@@ -309,3 +311,3 @@ if (isIntersecting || intersectionRatio > threshold) {

* { root: { stringifiedOptions: { observer, elements: []...] } }
* @method _findRoot
* @method findRootFromRegistry
* @param {HTMLElement|Window} root

@@ -315,3 +317,3 @@ * @private

*/
IntersectionObserverAdmin.prototype._findRoot = function (root) {
IntersectionObserverAdmin.prototype.findRootFromRegistry = function (root) {
if (this.elementRegistry) {

@@ -325,11 +327,11 @@ return this.elementRegistry.getElement(root);

*
* @method _findMatchingRootEntry
* @method findMatchingRootEntry
* @param {Object} options
* @return {Object} entry with elements and other options
*/
IntersectionObserverAdmin.prototype._findMatchingRootEntry = function (options) {
IntersectionObserverAdmin.prototype.findMatchingRootEntry = function (options) {
var _a = options.root, root = _a === void 0 ? window : _a;
var matchingRoot = this._findRoot(root);
var matchingRoot = this.findRootFromRegistry(root);
if (matchingRoot) {
var stringifiedOptions = this._stringifyOptions(options);
var stringifiedOptions = this.stringifyOptions(options);
return matchingRoot[stringifiedOptions];

@@ -342,3 +344,3 @@ }

*
* @method _determineMatchingElements
* @method determineMatchingElements
* @param {Object} options

@@ -349,9 +351,9 @@ * @param {Object} potentialRootMatch e.g. { stringifiedOptions: { elements: [], ... }, stringifiedOptions: { elements: [], ... }}

*/
IntersectionObserverAdmin.prototype._determineMatchingElements = function (options, potentialRootMatch) {
IntersectionObserverAdmin.prototype.determineMatchingElements = function (options, potentialRootMatch) {
var _this = this;
var matchingKey = Object.keys(potentialRootMatch).filter(function (key) {
var matchingStringifiedOptions = Object.keys(potentialRootMatch).filter(function (key) {
var comparableOptions = potentialRootMatch[key].options;
return _this._areOptionsSame(options, comparableOptions);
return _this.areOptionsSame(options, comparableOptions);
})[0];
return potentialRootMatch[matchingKey];
return potentialRootMatch[matchingStringifiedOptions];
};

@@ -362,3 +364,3 @@ /**

*
* @method _areOptionsSame
* @method areOptionsSame
* @param {any} a

@@ -369,3 +371,3 @@ * @param {any} b

*/
IntersectionObserverAdmin.prototype._areOptionsSame = function (a, b) {
IntersectionObserverAdmin.prototype.areOptionsSame = function (a, b) {
if (a === b) {

@@ -386,5 +388,5 @@ return true;

for (var key in a) {
if (a.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(a, key)) {
// recursion to check nested
if (this._areOptionsSame(a[key], b[key]) === false) {
if (this.areOptionsSame(a[key], b[key]) === false) {
return false;

@@ -406,3 +408,3 @@ }

*/
IntersectionObserverAdmin.prototype._stringifyOptions = function (options) {
IntersectionObserverAdmin.prototype.stringifyOptions = function (options) {
var root = options.root;

@@ -409,0 +411,0 @@ var replacer = function (key, value) {

@@ -23,4 +23,4 @@ (function (global, factory) {

* @param {IOption} options
* @param {IOption.root} root - contains optional root e.g. window, container div, etc
* @param {IOption.watcher} observer - optional
* @param {IOption.root} [root] - contains optional root e.g. window, container div, etc
* @param {IOption.watcher} [observer] - optional
* @public

@@ -125,3 +125,3 @@ */

*
* @method add
* @method observe
* @param {HTMLElement | Window} element

@@ -148,3 +148,3 @@ * @param {Object} options

IntersectionObserverAdmin.prototype.unobserve = function (target, options) {
var matchingRootEntry = this._findMatchingRootEntry(options);
var matchingRootEntry = this.findMatchingRootEntry(options);
if (matchingRootEntry) {

@@ -215,10 +215,10 @@ var intersectionObserver = matchingRootEntry.intersectionObserver;

var _b = options.root, root = _b === void 0 ? window : _b;
// find shared root element (window or target HTMLElement)
// First - find shared root element (window or target HTMLElement)
// this root is responsible for coordinating it's set of elements
var potentialRootMatch = this._findRoot(root);
// third if there is a matching root, see if an existing entry with the same options
// regardless of sort order. This is a bit of work
var potentialRootMatch = this.findRootFromRegistry(root);
// Second - if there is a matching root, see if an existing entry with the same options
// regardless of sort order. This is a bit of work
var matchingEntryForRoot;
if (potentialRootMatch) {
matchingEntryForRoot = this._determineMatchingElements(options, potentialRootMatch);
matchingEntryForRoot = this.determineMatchingElements(options, potentialRootMatch);
}

@@ -244,3 +244,3 @@ // next add found entry to elements and call observer if applicable

// with watcher so we can use it later on
var stringifiedOptions = this._stringifyOptions(options);
var stringifiedOptions = this.stringifyOptions(options);
if (potentialRootMatch) {

@@ -270,2 +270,4 @@ // if share same root and need to add new entry to root match

* configured `threshold`s.
* Exit callback occurs eagerly (when element is initially out of scope)
* See https://stackoverflow.com/questions/53214116/intersectionobserver-callback-firing-immediately-on-page-load/53385264#53385264
*

@@ -286,3 +288,3 @@ * @method onIntersection

// then find entry's callback in static administration
var matchingRootEntry = _this._findMatchingRootEntry(options);
var matchingRootEntry = _this.findMatchingRootEntry(options);
// first determine if entry intersecting

@@ -315,3 +317,3 @@ if (isIntersecting || intersectionRatio > threshold) {

* { root: { stringifiedOptions: { observer, elements: []...] } }
* @method _findRoot
* @method findRootFromRegistry
* @param {HTMLElement|Window} root

@@ -321,3 +323,3 @@ * @private

*/
IntersectionObserverAdmin.prototype._findRoot = function (root) {
IntersectionObserverAdmin.prototype.findRootFromRegistry = function (root) {
if (this.elementRegistry) {

@@ -331,11 +333,11 @@ return this.elementRegistry.getElement(root);

*
* @method _findMatchingRootEntry
* @method findMatchingRootEntry
* @param {Object} options
* @return {Object} entry with elements and other options
*/
IntersectionObserverAdmin.prototype._findMatchingRootEntry = function (options) {
IntersectionObserverAdmin.prototype.findMatchingRootEntry = function (options) {
var _a = options.root, root = _a === void 0 ? window : _a;
var matchingRoot = this._findRoot(root);
var matchingRoot = this.findRootFromRegistry(root);
if (matchingRoot) {
var stringifiedOptions = this._stringifyOptions(options);
var stringifiedOptions = this.stringifyOptions(options);
return matchingRoot[stringifiedOptions];

@@ -348,3 +350,3 @@ }

*
* @method _determineMatchingElements
* @method determineMatchingElements
* @param {Object} options

@@ -355,9 +357,9 @@ * @param {Object} potentialRootMatch e.g. { stringifiedOptions: { elements: [], ... }, stringifiedOptions: { elements: [], ... }}

*/
IntersectionObserverAdmin.prototype._determineMatchingElements = function (options, potentialRootMatch) {
IntersectionObserverAdmin.prototype.determineMatchingElements = function (options, potentialRootMatch) {
var _this = this;
var matchingKey = Object.keys(potentialRootMatch).filter(function (key) {
var matchingStringifiedOptions = Object.keys(potentialRootMatch).filter(function (key) {
var comparableOptions = potentialRootMatch[key].options;
return _this._areOptionsSame(options, comparableOptions);
return _this.areOptionsSame(options, comparableOptions);
})[0];
return potentialRootMatch[matchingKey];
return potentialRootMatch[matchingStringifiedOptions];
};

@@ -368,3 +370,3 @@ /**

*
* @method _areOptionsSame
* @method areOptionsSame
* @param {any} a

@@ -375,3 +377,3 @@ * @param {any} b

*/
IntersectionObserverAdmin.prototype._areOptionsSame = function (a, b) {
IntersectionObserverAdmin.prototype.areOptionsSame = function (a, b) {
if (a === b) {

@@ -392,5 +394,5 @@ return true;

for (var key in a) {
if (a.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(a, key)) {
// recursion to check nested
if (this._areOptionsSame(a[key], b[key]) === false) {
if (this.areOptionsSame(a[key], b[key]) === false) {
return false;

@@ -412,3 +414,3 @@ }

*/
IntersectionObserverAdmin.prototype._stringifyOptions = function (options) {
IntersectionObserverAdmin.prototype.stringifyOptions = function (options) {
var root = options.root;

@@ -415,0 +417,0 @@ var replacer = function (key, value) {

@@ -15,3 +15,3 @@ import Notifications from './notification';

*
* @method add
* @method observe
* @param {HTMLElement | Window} element

@@ -79,2 +79,4 @@ * @param {Object} options

* configured `threshold`s.
* Exit callback occurs eagerly (when element is initially out of scope)
* See https://stackoverflow.com/questions/53214116/intersectionobserver-callback-firing-immediately-on-page-load/53385264#53385264
*

@@ -89,3 +91,3 @@ * @method onIntersection

* { root: { stringifiedOptions: { observer, elements: []...] } }
* @method _findRoot
* @method findRootFromRegistry
* @param {HTMLElement|Window} root

@@ -95,3 +97,3 @@ * @private

*/
private _findRoot;
private findRootFromRegistry;
/**

@@ -101,7 +103,7 @@ * We don't care about options key order because we already added

*
* @method _findMatchingRootEntry
* @method findMatchingRootEntry
* @param {Object} options
* @return {Object} entry with elements and other options
*/
private _findMatchingRootEntry;
private findMatchingRootEntry;
/**

@@ -111,3 +113,3 @@ * Determine if existing elements for a given root based on passed in options

*
* @method _determineMatchingElements
* @method determineMatchingElements
* @param {Object} options

@@ -118,3 +120,3 @@ * @param {Object} potentialRootMatch e.g. { stringifiedOptions: { elements: [], ... }, stringifiedOptions: { elements: [], ... }}

*/
private _determineMatchingElements;
private determineMatchingElements;
/**

@@ -124,3 +126,3 @@ * recursive method to test primitive string, number, null, etc and complex

*
* @method _areOptionsSame
* @method areOptionsSame
* @param {any} a

@@ -131,3 +133,3 @@ * @param {any} b

*/
private _areOptionsSame;
private areOptionsSame;
/**

@@ -141,3 +143,3 @@ * Stringify options for use as a key.

*/
private _stringifyOptions;
private stringifyOptions;
}

@@ -15,4 +15,4 @@ export interface IOptions {

* @param {IOption} options
* @param {IOption.root} root - contains optional root e.g. window, container div, etc
* @param {IOption.watcher} observer - optional
* @param {IOption.root} [root] - contains optional root e.g. window, container div, etc
* @param {IOption.watcher} [observer] - optional
* @public

@@ -19,0 +19,0 @@ */

{
"name": "intersection-observer-admin",
"version": "0.2.12",
"version": "0.2.13",
"description": "Intersection Observer Admin for better performance",

@@ -5,0 +5,0 @@ "main": "dist/intersection-observer-admin.umd.js",

@@ -86,3 +86,3 @@ intersection-observer-admin

<td>Safari</td>
<td>Safari Technology Preview</td>
<td>12.1</td>
</tr>

@@ -89,0 +89,0 @@ <tr>

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc