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 0.3.1 to 0.4.0

35

lib/DOMInteractions.js
const watchers = [];
const events = [
'resize',
'transitionend',
'animationend',
'animationstart',
'animationiteration',
'keyup',
'keydown',
'mouseup',
'mousedown',
'mouseover',
'blur',
'focus'
];
const dispatch = () => {
watchers.forEach((watcher) => watcher());
};
events.forEach(name => window.addEventListener(name, dispatch, true));
if ('MutationObserver' in window) {
const observerConfig = { attributes: true, characterData: true, childList: true, subtree: true };
new MutationObserver(dispatch).observe(document.body, observerConfig);
}
export default class DOMInteractions {

@@ -10,17 +29,1 @@ static watch(callback) {

}
document.addEventListener('keyup', dispatch, true);
document.addEventListener('keydown', dispatch, true);
document.addEventListener('mouseup', dispatch, true);
document.addEventListener('mousedown', dispatch, true);
document.addEventListener('mouseover', dispatch, true);
document.addEventListener('blur', dispatch, true);
document.addEventListener('focus', dispatch, true);
document.addEventListener('transitionend', dispatch, true);
document.addEventListener('animationend', dispatch, true);
document.addEventListener('animationstart', dispatch, true);
document.addEventListener('animationiteration', dispatch, true);
window.addEventListener('resize', dispatch);
if ('MutationObserver' in window) {
const observerConfig = { attributes: true, characterData: true, childList: true, subtree: true };
new MutationObserver(dispatch).observe(document.body, observerConfig);
}
{
"name": "@juggle/resize-observer",
"version": "0.3.1",
"version": "0.4.0",
"description": "ResizeObserver - Based on the official draft specification",

@@ -5,0 +5,0 @@ "main": "./lib/ResizeObserver.js",

type StandardCallback = () => any;
const watchers: StandardCallback[] = [];
const events = [
// Global Resize
'resize',
// Transitions & Animations
'transitionend',
'animationend',
'animationstart',
'animationiteration',
// Interactions
'keyup',
'keydown',
'mouseup',
'mousedown',
'mouseover',
'blur',
'focus'
];
// Dispatcher for interactions
const dispatch: StandardCallback = () => {

@@ -8,26 +27,5 @@ watchers.forEach((watcher: StandardCallback) => watcher());

export default class DOMInteractions {
public static watch (callback: StandardCallback) {
watchers.push(callback);
}
}
// Listen to events
events.forEach(name => window.addEventListener(name, dispatch, true));
// Listen to interaction
document.addEventListener('keyup', dispatch, true);
document.addEventListener('keydown', dispatch, true);
document.addEventListener('mouseup', dispatch, true);
document.addEventListener('mousedown', dispatch, true);
document.addEventListener('mouseover', dispatch, true);
document.addEventListener('blur', dispatch, true);
document.addEventListener('focus', dispatch, true);
// Listen to transitions and animations
document.addEventListener('transitionend', dispatch, true);
document.addEventListener('animationend', dispatch, true);
document.addEventListener('animationstart', dispatch, true);
document.addEventListener('animationiteration', dispatch, true);
// Listen for window resize
window.addEventListener('resize', dispatch);
// Listen for any other DOM changes which could affect sizes

@@ -37,2 +35,8 @@ if ('MutationObserver' in window) {

new MutationObserver(dispatch).observe(document.body, observerConfig);
}
export default class DOMInteractions {
public static watch (callback: StandardCallback) {
watchers.push(callback);
}
}
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