Socket
Socket
Sign inDemoInstall

@lit-labs/observers

Package Overview
Dependencies
Maintainers
9
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lit-labs/observers - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

21

development/intersection_controller.d.ts

@@ -10,7 +10,7 @@ /**

*/
export declare type IntersectionValueCallback = (...args: Parameters<IntersectionObserverCallback>) => unknown;
export declare type IntersectionValueCallback<T = unknown> = (...args: Parameters<IntersectionObserverCallback>) => T;
/**
* The config options for a IntersectionController.
*/
export interface IntersectionControllerConfig {
export interface IntersectionControllerConfig<T = unknown> {
/**

@@ -32,3 +32,3 @@ * Configuration object for the IntersectionObserver.

*/
callback?: IntersectionValueCallback;
callback?: IntersectionValueCallback<T>;
/**

@@ -57,5 +57,5 @@ * An IntersectionObserver reports the initial intersection state

*/
export declare class IntersectionController implements ReactiveController {
export declare class IntersectionController<T = unknown> implements ReactiveController {
private _host;
private _target;
private _targets;
private _observer;

@@ -75,3 +75,3 @@ private _skipInitial;

*/
value?: unknown;
value?: T;
/**

@@ -81,4 +81,4 @@ * Function that returns a value processed from the observer's changes.

*/
callback: IntersectionValueCallback;
constructor(host: ReactiveControllerHost, { target, config, callback, skipInitial }: IntersectionControllerConfig);
callback?: IntersectionValueCallback<T>;
constructor(host: ReactiveControllerHost & Element, { target, config, callback, skipInitial }: IntersectionControllerConfig<T>);
/**

@@ -99,2 +99,7 @@ * Process the observer's changes with the controller's `callback`

/**
* Unobserve the target element.
* @param target Element to unobserve
*/
unobserve(target: Element): void;
/**
* Disconnects the observer. This is done automatically when the host

@@ -101,0 +106,0 @@ * disconnects.

@@ -19,2 +19,3 @@ /**

constructor(host, { target, config, callback, skipInitial }) {
this._targets = new Set();
this._skipInitial = false;

@@ -29,13 +30,9 @@ /**

this._unobservedUpdate = false;
/**
* Function that returns a value processed from the observer's changes.
* The result is stored in the `value` property.
*/
this.callback = () => true;
(this._host = host).addController(this);
this._host = host;
// Target defaults to `host` unless explicitly `null`.
this._target =
target === null ? target : target !== null && target !== void 0 ? target : this._host;
if (target !== null) {
this._targets.add(target !== null && target !== void 0 ? target : host);
}
this._skipInitial = skipInitial !== null && skipInitial !== void 0 ? skipInitial : this._skipInitial;
this.callback = callback !== null && callback !== void 0 ? callback : this.callback;
this.callback = callback;
// Check browser support.

@@ -55,2 +52,3 @@ if (!window.IntersectionObserver) {

}, config);
host.addController(this);
}

@@ -62,7 +60,8 @@ /**

handleChanges(entries) {
this.value = this.callback(entries, this._observer);
var _a;
this.value = (_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, entries, this._observer);
}
hostConnected() {
if (this._target) {
this.observe(this._target);
for (const target of this._targets) {
this.observe(target);
}

@@ -86,2 +85,3 @@ }

observe(target) {
this._targets.add(target);
// Note, this will always trigger the callback since the initial

@@ -93,2 +93,10 @@ // intersection state is reported.

/**
* Unobserve the target element.
* @param target Element to unobserve
*/
unobserve(target) {
this._targets.delete(target);
this._observer.unobserve(target);
}
/**
* Disconnects the observer. This is done automatically when the host

@@ -95,0 +103,0 @@ * disconnects.

@@ -10,7 +10,7 @@ /**

*/
export declare type MutationValueCallback = (...args: Parameters<MutationCallback>) => unknown;
export declare type MutationValueCallback<T = unknown> = (...args: Parameters<MutationCallback>) => T;
/**
* The config options for a MutationController.
*/
export interface MutationControllerConfig {
export interface MutationControllerConfig<T = unknown> {
/**

@@ -32,3 +32,3 @@ * Configuration object for the MutationObserver.

*/
callback?: MutationValueCallback;
callback?: MutationValueCallback<T>;
/**

@@ -56,5 +56,5 @@ * By default the `callback` is called without changes when a target is

*/
export declare class MutationController implements ReactiveController {
export declare class MutationController<T = unknown> implements ReactiveController {
private _host;
private _target;
private _targets;
private _config;

@@ -74,3 +74,3 @@ private _observer;

*/
value?: unknown;
value?: T;
/**

@@ -80,4 +80,4 @@ * Function that returns a value processed from the observer's changes.

*/
callback: MutationValueCallback;
constructor(host: ReactiveControllerHost, { target, config, callback, skipInitial }: MutationControllerConfig);
callback?: MutationValueCallback<T>;
constructor(host: ReactiveControllerHost & Element, { target, config, callback, skipInitial }: MutationControllerConfig<T>);
/**

@@ -84,0 +84,0 @@ * Process the observer's changes with the controller's `callback`

@@ -18,2 +18,3 @@ /**

constructor(host, { target, config, callback, skipInitial }) {
this._targets = new Set();
this._skipInitial = false;

@@ -27,14 +28,10 @@ /**

this._unobservedUpdate = false;
/**
* Function that returns a value processed from the observer's changes.
* The result is stored in the `value` property.
*/
this.callback = () => true;
(this._host = host).addController(this);
this._host = host;
// Target defaults to `host` unless explicitly `null`.
this._target =
target === null ? target : target !== null && target !== void 0 ? target : this._host;
if (target !== null) {
this._targets.add(target !== null && target !== void 0 ? target : host);
}
this._config = config;
this._skipInitial = skipInitial !== null && skipInitial !== void 0 ? skipInitial : this._skipInitial;
this.callback = callback !== null && callback !== void 0 ? callback : this.callback;
this.callback = callback;
// Check browser support.

@@ -49,2 +46,3 @@ if (!window.MutationObserver) {

});
host.addController(this);
}

@@ -56,7 +54,8 @@ /**

handleChanges(records) {
this.value = this.callback(records, this._observer);
var _a;
this.value = (_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, records, this._observer);
}
hostConnected() {
if (this._target) {
this.observe(this._target);
for (const target of this._targets) {
this.observe(target);
}

@@ -85,2 +84,3 @@ }

observe(target) {
this._targets.add(target);
this._observer.observe(target, this._config);

@@ -87,0 +87,0 @@ this._unobservedUpdate = true;

@@ -10,7 +10,7 @@ /**

*/
export declare type PerformanceValueCallback = (entries: PerformanceEntryList, observer: PerformanceObserver, entryList?: PerformanceObserverEntryList) => unknown;
export declare type PerformanceValueCallback<T = unknown> = (entries: PerformanceEntryList, observer: PerformanceObserver, entryList?: PerformanceObserverEntryList) => T;
/**
* The config options for a PerformanceController.
*/
export interface PerformanceControllerConfig {
export interface PerformanceControllerConfig<T = unknown> {
/**

@@ -24,3 +24,3 @@ * Configuration object for the PerformanceObserver.

*/
callback?: PerformanceValueCallback;
callback?: PerformanceValueCallback<T>;
/**

@@ -45,3 +45,3 @@ * By default the `callback` is called without changes when a target is

*/
export declare class PerformanceController implements ReactiveController {
export declare class PerformanceController<T = unknown> implements ReactiveController {
private _host;

@@ -62,3 +62,3 @@ private _config;

*/
value?: unknown;
value?: T;
/**

@@ -68,4 +68,4 @@ * Function that returns a value processed from the observer's changes.

*/
callback: PerformanceValueCallback;
constructor(host: ReactiveControllerHost, { config, callback, skipInitial }: PerformanceControllerConfig);
callback?: PerformanceValueCallback<T>;
constructor(host: ReactiveControllerHost, { config, callback, skipInitial }: PerformanceControllerConfig<T>);
/**

@@ -72,0 +72,0 @@ * Process the observer's changes with the controller's `callback`

@@ -23,11 +23,6 @@ /**

this._unobservedUpdate = false;
/**
* Function that returns a value processed from the observer's changes.
* The result is stored in the `value` property.
*/
this.callback = () => true;
(this._host = host).addController(this);
this._host = host;
this._config = config;
this._skipInitial = skipInitial !== null && skipInitial !== void 0 ? skipInitial : this._skipInitial;
this.callback = callback !== null && callback !== void 0 ? callback : this.callback;
this.callback = callback;
// Check browser support.

@@ -42,2 +37,3 @@ if (!window.PerformanceObserver) {

});
host.addController(this);
}

@@ -49,3 +45,4 @@ /**

handleChanges(entries, entryList) {
this.value = this.callback(entries, this._observer, entryList);
var _a;
this.value = (_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, entries, this._observer, entryList);
}

@@ -52,0 +49,0 @@ hostConnected() {

@@ -10,7 +10,7 @@ /**

*/
export declare type ResizeValueCallback = (...args: Parameters<ResizeObserverCallback>) => unknown;
export declare type ResizeValueCallback<T = unknown> = (...args: Parameters<ResizeObserverCallback>) => T;
/**
* The config options for a ResizeController.
*/
export interface ResizeControllerConfig {
export interface ResizeControllerConfig<T = unknown> {
/**

@@ -32,3 +32,3 @@ * Configuration object for the ResizeController.

*/
callback?: ResizeValueCallback;
callback?: ResizeValueCallback<T>;
/**

@@ -55,5 +55,5 @@ * By default the `callback` is called without changes when a target is

*/
export declare class ResizeController implements ReactiveController {
export declare class ResizeController<T = unknown> implements ReactiveController {
private _host;
private _target;
private _targets;
private _config?;

@@ -73,3 +73,3 @@ private _observer;

*/
value?: unknown;
value?: T;
/**

@@ -79,4 +79,4 @@ * Function that returns a value processed from the observer's changes.

*/
callback: ResizeValueCallback;
constructor(host: ReactiveControllerHost, { target, config, callback, skipInitial }: ResizeControllerConfig);
callback?: ResizeValueCallback<T>;
constructor(host: ReactiveControllerHost & Element, { target, config, callback, skipInitial }: ResizeControllerConfig<T>);
/**

@@ -97,2 +97,7 @@ * Process the observer's changes with the controller's `callback`

/**
* Unobserve the target element.
* @param target Element to unobserve
*/
unobserve(target: Element): void;
/**
* Disconnects the observer. This is done automatically when the host

@@ -99,0 +104,0 @@ * disconnects.

@@ -17,2 +17,3 @@ /**

constructor(host, { target, config, callback, skipInitial }) {
this._targets = new Set();
this._skipInitial = false;

@@ -26,14 +27,10 @@ /**

this._unobservedUpdate = false;
/**
* Function that returns a value processed from the observer's changes.
* The result is stored in the `value` property.
*/
this.callback = () => true;
(this._host = host).addController(this);
this._host = host;
// Target defaults to `host` unless explicitly `null`.
this._target =
target === null ? target : target !== null && target !== void 0 ? target : this._host;
if (target !== null) {
this._targets.add(target !== null && target !== void 0 ? target : host);
}
this._config = config;
this._skipInitial = skipInitial !== null && skipInitial !== void 0 ? skipInitial : this._skipInitial;
this.callback = callback !== null && callback !== void 0 ? callback : this.callback;
this.callback = callback;
// Check browser support.

@@ -48,2 +45,3 @@ if (!window.ResizeObserver) {

});
host.addController(this);
}

@@ -55,7 +53,8 @@ /**

handleChanges(entries) {
this.value = this.callback(entries, this._observer);
var _a;
this.value = (_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, entries, this._observer);
}
hostConnected() {
if (this._target) {
this.observe(this._target);
for (const target of this._targets) {
this.observe(target);
}

@@ -81,2 +80,3 @@ }

observe(target) {
this._targets.add(target);
this._observer.observe(target, this._config);

@@ -87,2 +87,10 @@ this._unobservedUpdate = true;

/**
* Unobserve the target element.
* @param target Element to unobserve
*/
unobserve(target) {
this._targets.delete(target);
this._observer.unobserve(target);
}
/**
* Disconnects the observer. This is done automatically when the host

@@ -89,0 +97,0 @@ * disconnects.

@@ -10,7 +10,7 @@ /**

*/
export declare type IntersectionValueCallback = (...args: Parameters<IntersectionObserverCallback>) => unknown;
export declare type IntersectionValueCallback<T = unknown> = (...args: Parameters<IntersectionObserverCallback>) => T;
/**
* The config options for a IntersectionController.
*/
export interface IntersectionControllerConfig {
export interface IntersectionControllerConfig<T = unknown> {
/**

@@ -32,3 +32,3 @@ * Configuration object for the IntersectionObserver.

*/
callback?: IntersectionValueCallback;
callback?: IntersectionValueCallback<T>;
/**

@@ -57,5 +57,5 @@ * An IntersectionObserver reports the initial intersection state

*/
export declare class IntersectionController implements ReactiveController {
export declare class IntersectionController<T = unknown> implements ReactiveController {
private _host;
private _target;
private _targets;
private _observer;

@@ -75,3 +75,3 @@ private _skipInitial;

*/
value?: unknown;
value?: T;
/**

@@ -81,4 +81,4 @@ * Function that returns a value processed from the observer's changes.

*/
callback: IntersectionValueCallback;
constructor(host: ReactiveControllerHost, { target, config, callback, skipInitial }: IntersectionControllerConfig);
callback?: IntersectionValueCallback<T>;
constructor(host: ReactiveControllerHost & Element, { target, config, callback, skipInitial }: IntersectionControllerConfig<T>);
/**

@@ -99,2 +99,7 @@ * Process the observer's changes with the controller's `callback`

/**
* Unobserve the target element.
* @param target Element to unobserve
*/
unobserve(target: Element): void;
/**
* Disconnects the observer. This is done automatically when the host

@@ -101,0 +106,0 @@ * disconnects.

@@ -1,2 +0,2 @@

class t{constructor(t,{target:s,config:i,callback:h,skipInitial:n}){this.t=!1,this.o=!1,this.callback=()=>!0,(this.i=t).addController(this),this.h=null===s||null!=s?s:this.i,this.t=null!=n?n:this.t,this.callback=null!=h?h:this.callback,window.IntersectionObserver?this.u=new IntersectionObserver((t=>{const s=this.o;this.o=!1,this.t&&s||(this.handleChanges(t),this.i.requestUpdate())}),i):console.warn("IntersectionController error: browser does not support IntersectionObserver.")}handleChanges(t){this.value=this.callback(t,this.u)}hostConnected(){this.h&&this.observe(this.h)}hostDisconnected(){this.disconnect()}async hostUpdated(){const t=this.u.takeRecords();t.length&&this.handleChanges(t)}observe(t){this.u.observe(t),this.o=!0}disconnect(){this.u.disconnect()}}export{t as IntersectionController};
class t{constructor(t,{target:s,config:i,callback:h,skipInitial:e}){this.t=new Set,this.o=!1,this.i=!1,this.h=t,null!==s&&this.t.add(null!=s?s:t),this.o=null!=e?e:this.o,this.callback=h,window.IntersectionObserver?(this.u=new IntersectionObserver((t=>{const s=this.i;this.i=!1,this.o&&s||(this.handleChanges(t),this.h.requestUpdate())}),i),t.addController(this)):console.warn("IntersectionController error: browser does not support IntersectionObserver.")}handleChanges(t){var s;this.value=null===(s=this.callback)||void 0===s?void 0:s.call(this,t,this.u)}hostConnected(){for(const t of this.t)this.observe(t)}hostDisconnected(){this.disconnect()}async hostUpdated(){const t=this.u.takeRecords();t.length&&this.handleChanges(t)}observe(t){this.t.add(t),this.u.observe(t),this.i=!0}unobserve(t){this.t.delete(t),this.u.unobserve(t)}disconnect(){this.u.disconnect()}}export{t as IntersectionController};
//# sourceMappingURL=intersection_controller.js.map

@@ -10,7 +10,7 @@ /**

*/
export declare type MutationValueCallback = (...args: Parameters<MutationCallback>) => unknown;
export declare type MutationValueCallback<T = unknown> = (...args: Parameters<MutationCallback>) => T;
/**
* The config options for a MutationController.
*/
export interface MutationControllerConfig {
export interface MutationControllerConfig<T = unknown> {
/**

@@ -32,3 +32,3 @@ * Configuration object for the MutationObserver.

*/
callback?: MutationValueCallback;
callback?: MutationValueCallback<T>;
/**

@@ -56,5 +56,5 @@ * By default the `callback` is called without changes when a target is

*/
export declare class MutationController implements ReactiveController {
export declare class MutationController<T = unknown> implements ReactiveController {
private _host;
private _target;
private _targets;
private _config;

@@ -74,3 +74,3 @@ private _observer;

*/
value?: unknown;
value?: T;
/**

@@ -80,4 +80,4 @@ * Function that returns a value processed from the observer's changes.

*/
callback: MutationValueCallback;
constructor(host: ReactiveControllerHost, { target, config, callback, skipInitial }: MutationControllerConfig);
callback?: MutationValueCallback<T>;
constructor(host: ReactiveControllerHost & Element, { target, config, callback, skipInitial }: MutationControllerConfig<T>);
/**

@@ -84,0 +84,0 @@ * Process the observer's changes with the controller's `callback`

@@ -1,2 +0,2 @@

class t{constructor(t,{target:s,config:i,callback:h,skipInitial:n}){this.t=!1,this.o=!1,this.callback=()=>!0,(this.i=t).addController(this),this.h=null===s||null!=s?s:this.i,this.l=i,this.t=null!=n?n:this.t,this.callback=null!=h?h:this.callback,window.MutationObserver?this.u=new MutationObserver((t=>{this.handleChanges(t),this.i.requestUpdate()})):console.warn("MutationController error: browser does not support MutationObserver.")}handleChanges(t){this.value=this.callback(t,this.u)}hostConnected(){this.h&&this.observe(this.h)}hostDisconnected(){this.disconnect()}async hostUpdated(){const t=this.u.takeRecords();(t.length||!this.t&&this.o)&&this.handleChanges(t),this.o=!1}observe(t){this.u.observe(t,this.l),this.o=!0,this.i.requestUpdate()}disconnect(){this.u.disconnect()}}export{t as MutationController};
class t{constructor(t,{target:s,config:i,callback:h,skipInitial:o}){this.t=new Set,this.o=!1,this.i=!1,this.h=t,null!==s&&this.t.add(null!=s?s:t),this.l=i,this.o=null!=o?o:this.o,this.callback=h,window.MutationObserver?(this.u=new MutationObserver((t=>{this.handleChanges(t),this.h.requestUpdate()})),t.addController(this)):console.warn("MutationController error: browser does not support MutationObserver.")}handleChanges(t){var s;this.value=null===(s=this.callback)||void 0===s?void 0:s.call(this,t,this.u)}hostConnected(){for(const t of this.t)this.observe(t)}hostDisconnected(){this.disconnect()}async hostUpdated(){const t=this.u.takeRecords();(t.length||!this.o&&this.i)&&this.handleChanges(t),this.i=!1}observe(t){this.t.add(t),this.u.observe(t,this.l),this.i=!0,this.h.requestUpdate()}disconnect(){this.u.disconnect()}}export{t as MutationController};
//# sourceMappingURL=mutation_controller.js.map
{
"name": "@lit-labs/observers",
"version": "1.0.2",
"version": "1.1.0",
"description": "A set of reactive controllers that facilitate using the platform observer objects.",

@@ -5,0 +5,0 @@ "license": "BSD-3-Clause",

@@ -10,7 +10,7 @@ /**

*/
export declare type PerformanceValueCallback = (entries: PerformanceEntryList, observer: PerformanceObserver, entryList?: PerformanceObserverEntryList) => unknown;
export declare type PerformanceValueCallback<T = unknown> = (entries: PerformanceEntryList, observer: PerformanceObserver, entryList?: PerformanceObserverEntryList) => T;
/**
* The config options for a PerformanceController.
*/
export interface PerformanceControllerConfig {
export interface PerformanceControllerConfig<T = unknown> {
/**

@@ -24,3 +24,3 @@ * Configuration object for the PerformanceObserver.

*/
callback?: PerformanceValueCallback;
callback?: PerformanceValueCallback<T>;
/**

@@ -45,3 +45,3 @@ * By default the `callback` is called without changes when a target is

*/
export declare class PerformanceController implements ReactiveController {
export declare class PerformanceController<T = unknown> implements ReactiveController {
private _host;

@@ -62,3 +62,3 @@ private _config;

*/
value?: unknown;
value?: T;
/**

@@ -68,4 +68,4 @@ * Function that returns a value processed from the observer's changes.

*/
callback: PerformanceValueCallback;
constructor(host: ReactiveControllerHost, { config, callback, skipInitial }: PerformanceControllerConfig);
callback?: PerformanceValueCallback<T>;
constructor(host: ReactiveControllerHost, { config, callback, skipInitial }: PerformanceControllerConfig<T>);
/**

@@ -72,0 +72,0 @@ * Process the observer's changes with the controller's `callback`

@@ -1,2 +0,2 @@

class s{constructor(s,{config:t,callback:i,skipInitial:h}){this.t=!1,this.o=!1,this.callback=()=>!0,(this.i=s).addController(this),this.l=t,this.t=null!=h?h:this.t,this.callback=null!=i?i:this.callback,window.PerformanceObserver?this.u=new PerformanceObserver((s=>{this.handleChanges(s.getEntries(),s),this.i.requestUpdate()})):console.warn("PerformanceController error: browser does not support PerformanceObserver.")}handleChanges(s,t){this.value=this.callback(s,this.u,t)}hostConnected(){this.observe()}hostDisconnected(){this.disconnect()}async hostUpdated(){const s=this.u.takeRecords();(s.length||!this.t&&this.o)&&this.handleChanges(s),this.o=!1}flush(){const s=this.u.takeRecords();s.length&&(this.handleChanges(s),this.i.requestUpdate())}observe(){this.u.observe(this.l),this.o=!0,this.i.requestUpdate()}disconnect(){this.u.disconnect()}}export{s as PerformanceController};
class s{constructor(s,{config:t,callback:i,skipInitial:h}){this.o=!1,this.i=!1,this.h=s,this.l=t,this.o=null!=h?h:this.o,this.callback=i,window.PerformanceObserver?(this.u=new PerformanceObserver((s=>{this.handleChanges(s.getEntries(),s),this.h.requestUpdate()})),s.addController(this)):console.warn("PerformanceController error: browser does not support PerformanceObserver.")}handleChanges(s,t){var i;this.value=null===(i=this.callback)||void 0===i?void 0:i.call(this,s,this.u,t)}hostConnected(){this.observe()}hostDisconnected(){this.disconnect()}async hostUpdated(){const s=this.u.takeRecords();(s.length||!this.o&&this.i)&&this.handleChanges(s),this.i=!1}flush(){const s=this.u.takeRecords();s.length&&(this.handleChanges(s),this.h.requestUpdate())}observe(){this.u.observe(this.l),this.i=!0,this.h.requestUpdate()}disconnect(){this.u.disconnect()}}export{s as PerformanceController};
//# sourceMappingURL=performance_controller.js.map

@@ -10,7 +10,7 @@ /**

*/
export declare type ResizeValueCallback = (...args: Parameters<ResizeObserverCallback>) => unknown;
export declare type ResizeValueCallback<T = unknown> = (...args: Parameters<ResizeObserverCallback>) => T;
/**
* The config options for a ResizeController.
*/
export interface ResizeControllerConfig {
export interface ResizeControllerConfig<T = unknown> {
/**

@@ -32,3 +32,3 @@ * Configuration object for the ResizeController.

*/
callback?: ResizeValueCallback;
callback?: ResizeValueCallback<T>;
/**

@@ -55,5 +55,5 @@ * By default the `callback` is called without changes when a target is

*/
export declare class ResizeController implements ReactiveController {
export declare class ResizeController<T = unknown> implements ReactiveController {
private _host;
private _target;
private _targets;
private _config?;

@@ -73,3 +73,3 @@ private _observer;

*/
value?: unknown;
value?: T;
/**

@@ -79,4 +79,4 @@ * Function that returns a value processed from the observer's changes.

*/
callback: ResizeValueCallback;
constructor(host: ReactiveControllerHost, { target, config, callback, skipInitial }: ResizeControllerConfig);
callback?: ResizeValueCallback<T>;
constructor(host: ReactiveControllerHost & Element, { target, config, callback, skipInitial }: ResizeControllerConfig<T>);
/**

@@ -97,2 +97,7 @@ * Process the observer's changes with the controller's `callback`

/**
* Unobserve the target element.
* @param target Element to unobserve
*/
unobserve(target: Element): void;
/**
* Disconnects the observer. This is done automatically when the host

@@ -99,0 +104,0 @@ * disconnects.

@@ -1,2 +0,2 @@

class s{constructor(s,{target:t,config:i,callback:h,skipInitial:e}){this.t=!1,this.o=!1,this.callback=()=>!0,(this.i=s).addController(this),this.h=null===t||null!=t?t:this.i,this.l=i,this.t=null!=e?e:this.t,this.callback=null!=h?h:this.callback,window.ResizeObserver?this.u=new ResizeObserver((s=>{this.handleChanges(s),this.i.requestUpdate()})):console.warn("ResizeController error: browser does not support ResizeObserver.")}handleChanges(s){this.value=this.callback(s,this.u)}hostConnected(){this.h&&this.observe(this.h)}hostDisconnected(){this.disconnect()}async hostUpdated(){!this.t&&this.o&&this.handleChanges([]),this.o=!1}observe(s){this.u.observe(s,this.l),this.o=!0,this.i.requestUpdate()}disconnect(){this.u.disconnect()}}export{s as ResizeController};
class s{constructor(s,{target:t,config:i,callback:h,skipInitial:e}){this.t=new Set,this.o=!1,this.i=!1,this.h=s,null!==t&&this.t.add(null!=t?t:s),this.l=i,this.o=null!=e?e:this.o,this.callback=h,window.ResizeObserver?(this.u=new ResizeObserver((s=>{this.handleChanges(s),this.h.requestUpdate()})),s.addController(this)):console.warn("ResizeController error: browser does not support ResizeObserver.")}handleChanges(s){var t;this.value=null===(t=this.callback)||void 0===t?void 0:t.call(this,s,this.u)}hostConnected(){for(const s of this.t)this.observe(s)}hostDisconnected(){this.disconnect()}async hostUpdated(){!this.o&&this.i&&this.handleChanges([]),this.i=!1}observe(s){this.t.add(s),this.u.observe(s,this.l),this.i=!0,this.h.requestUpdate()}unobserve(s){this.t.delete(s),this.u.unobserve(s)}disconnect(){this.u.disconnect()}}export{s as ResizeController};
//# sourceMappingURL=resize_controller.js.map

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

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

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

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