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

@juggle/resize-observer

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@juggle/resize-observer - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

lib/utils/queueMicroTask.d.ts

3

lib/ResizeObserver.js
import { ResizeObserverController } from './ResizeObserverController';
import { POLYFILL_CONSOLE_OUTPUT } from './utils/prettify';
var ResizeObserver = (function () {

@@ -35,3 +34,3 @@ function ResizeObserver(callback) {

ResizeObserver.toString = function () {
return POLYFILL_CONSOLE_OUTPUT;
return 'function ResizeObserver () { [polyfill code] }';
};

@@ -38,0 +37,0 @@ return ResizeObserver;

@@ -13,2 +13,3 @@ import { ResizeObserver } from './ResizeObserver';

}
export { ResizeObserverController, resizeObservers, process };
declare const isWatching: () => boolean;
export { ResizeObserverController, resizeObservers, process, isWatching };

@@ -75,2 +75,3 @@ import { scheduler } from './utils/scheduler';

}());
export { ResizeObserverController, resizeObservers, process };
var isWatching = function () { return !!watching; };
export { ResizeObserverController, resizeObservers, process, isWatching };

@@ -1,6 +0,5 @@

import { process } from '../ResizeObserverController';
import { prettifyConsoleOutput } from './prettify';
import { process, isWatching } from '../ResizeObserverController';
import { global } from './global';
import { queueResizeObserver } from './queueResizeObserver';
var CATCH_FRAMES = 60 / 5;
var requestAnimationFrame = global.requestAnimationFrame;
var observerConfig = { attributes: true, characterData: true, childList: true, subtree: true };

@@ -23,34 +22,3 @@ var events = [

];
var rafSlot = new Map();
var resizeObserverSlot = new Map();
var scheduled;
var dispatchCallbacksOnNextFrame = function () {
if (scheduled) {
return;
}
scheduled = true;
function runSchedule(t) {
scheduled = false;
var frameCallbacks = [];
var resizeObserverCallbacks = [];
rafSlot.forEach(function (callback) { return frameCallbacks.push(callback); });
resizeObserverSlot.forEach(function (callback) { return resizeObserverCallbacks.push(callback); });
rafSlot.clear();
resizeObserverSlot.clear();
try {
for (var _i = 0, frameCallbacks_1 = frameCallbacks; _i < frameCallbacks_1.length; _i++) {
var callback = frameCallbacks_1[_i];
callback(t);
}
}
finally {
for (var _a = 0, resizeObserverCallbacks_1 = resizeObserverCallbacks; _a < resizeObserverCallbacks_1.length; _a++) {
var callback = resizeObserverCallbacks_1[_a];
callback(t);
}
}
}
;
requestAnimationFrame(runSchedule);
};
var scheduled = false;
var Scheduler = (function () {

@@ -63,4 +31,8 @@ function Scheduler() {

Scheduler.prototype.run = function (frames) {
var scheduler = this;
resizeObserverSlot.set(this, function ResizeObserver() {
var _this = this;
if (scheduled) {
return;
}
scheduled = true;
queueResizeObserver(function () {
var elementsHaveResized = false;

@@ -71,14 +43,17 @@ try {

finally {
scheduled = false;
if (!isWatching()) {
return;
}
if (elementsHaveResized) {
scheduler.run(60);
_this.run(60);
}
else if (frames) {
scheduler.run(frames - 1);
_this.run(frames - 1);
}
else {
scheduler.start();
_this.start();
}
}
});
dispatchCallbacksOnNextFrame();
};

@@ -98,6 +73,4 @@ Scheduler.prototype.schedule = function () {

this.stopped = false;
if ('MutationObserver' in global) {
this.observer = new MutationObserver(this.listener);
this.observe();
}
this.observer = new MutationObserver(this.listener);
this.observe();
events.forEach(function (name) { return global.addEventListener(name, _this.listener, true); });

@@ -117,17 +90,2 @@ }

var scheduler = new Scheduler();
var rafIdBase = 0;
global.requestAnimationFrame = function (callback) {
if (typeof callback !== 'function') {
throw new Error('requestAnimationFrame expects 1 callback argument of type function.');
}
var handle = rafIdBase += 1;
rafSlot.set(handle, function AnimationFrame(t) { return callback(t); });
dispatchCallbacksOnNextFrame();
return handle;
};
global.cancelAnimationFrame = function (handle) {
rafSlot.delete(handle);
};
prettifyConsoleOutput(global.requestAnimationFrame);
prettifyConsoleOutput(global.cancelAnimationFrame);
export { scheduler };
{
"name": "@juggle/resize-observer",
"version": "2.3.0",
"version": "2.4.0",
"description": "Polyfills the ResizeObserver API and supports box size options from the latest spec",

@@ -62,3 +62,3 @@ "main": "./lib/ResizeObserver.js",

"jsdom": "^15.1.1",
"parcel-bundler": "^1.12.3",
"parcel-bundler": "^1.12.4",
"ts-jest": "^24.0.2",

@@ -65,0 +65,0 @@ "typescript": "^3.5.2"

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