New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

subscribe-ui-event

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

subscribe-ui-event - npm Package Compare versions

Comparing version 0.1.4 to 0.2.0

tmp/tests/unit/subscribe-ie8.js

4

dist/AugmentedEvent.js

@@ -19,4 +19,8 @@ /**

};
this.resize = {
width: 0,
height: 0
};
}
module.exports = ArgmentedEvent;

46

dist/eventHandlers/index.js

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

var AugmentedEvent = require('../AugmentedEvent');
var doc;
var docBody;
var docEl;
var ee = require('../eventEmitter').eventEmitter;
var leIE8 = require('../lib/leIE8');
var win;
var EVENT_END_DELAY = 200;
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
win = window;
doc = document;
docEl = doc.documentElement;
docBody = doc.body;
}
/**

@@ -121,3 +132,5 @@ * This is designed for cloning event object and IE8 event object doesn't have hasOwnProperty(),

function generateContinuousEventHandler(target, eventType, noThrottle) {
var enableScrollTop = false;
var enableScrollInfo = false;
var enableResizeInfo = false;
return function(eeType, options) {

@@ -131,3 +144,4 @@ if (ee.listeners(eeType, true)) {

var augmentedEvent = new AugmentedEvent({type: eventType});
enableScrollTop = enableScrollTop || options.enableScrollTop;
enableScrollInfo = enableScrollInfo || options.enableScrollInfo;
enableResizeInfo = enableResizeInfo || options.enableResizeInfo;

@@ -137,7 +151,11 @@ function eventHandler(e) {

var top;
if (enableScrollTop && ae.type === 'scroll') {
top = document.documentElement.scrollTop + document.body.scrollTop;
if (enableScrollInfo && ae.type === 'scroll') {
top = docEl.scrollTop + docBody.scrollTop;
ae.scroll.delta = top - ae.scroll.top;
ae.scroll.top = top;
}
if (enableResizeInfo && ae.type === 'resize') {
ae.resize.width = win.innerWidth || docEl.clientWidth;
ae.resize.height = win.innerHeight || docEl.clientHeight;
}
ee.emit(eeType, e, ae);

@@ -164,17 +182,17 @@ }

var handler = throttleRate > 0 ? throttle(eventHandler, throttleRate) : eventHandler;
listen(window, 'scroll', handler);
listen(window, 'resize', handler);
listen(win, 'scroll', handler);
listen(win, 'resize', handler);
// no throttle for visibilitychange, otherwise will call twice
listen(document, 'visibilitychange', eventHandler);
listen(win, 'visibilitychange', eventHandler);
}
module.exports = {
resize: generateContinuousEventHandler(window, 'resize'),
resizeEnd: generateEdgeEventHandler(window, 'resize', false),
resizeStart: generateEdgeEventHandler(window, 'resize', true),
scroll: generateContinuousEventHandler(window, 'scroll'),
scrollEnd: generateEdgeEventHandler(window, 'scroll', false),
scrollStart: generateEdgeEventHandler(window, 'scroll', true),
resize: generateContinuousEventHandler(win, 'resize'),
resizeEnd: generateEdgeEventHandler(win, 'resize', false),
resizeStart: generateEdgeEventHandler(win, 'resize', true),
scroll: generateContinuousEventHandler(win, 'scroll'),
scrollEnd: generateEdgeEventHandler(win, 'scroll', false),
scrollStart: generateEdgeEventHandler(win, 'scroll', true),
viewportchange: viewportchange,
visibilitychange: generateContinuousEventHandler(document, 'visibilitychange', true)
visibilitychange: generateContinuousEventHandler(doc, 'visibilitychange', true)
};

@@ -36,3 +36,4 @@ /**

var eeType; // emitEmitterType = eventType + ':' + throttle
var enableScrollTop = options.enableScrollTop || false;
var enableScrollInfo = options.enableScrollInfo || false;
var enableResizeInfo = options.enableResizeInfo || false;
var sub;

@@ -60,3 +61,4 @@ var throttleFunc;

eventHandlers[eventType](eeType, {
enableScrollTop: enableScrollTop,
enableScrollInfo: enableScrollInfo,
enableResizeInfo: enableResizeInfo,
throttleFunc: throttleFunc,

@@ -63,0 +65,0 @@ throttleRate: throttleRate

{
"name": "subscribe-ui-event",
"version": "0.1.4",
"version": "0.2.0",
"description": "A single, throttle built-in solution to subscribe to browser UI Events.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -77,4 +77,6 @@ # subscribe-ui-event

`options.enableScrollTop = true` allows of getting `scrollTop`.
`options.enableScrollInfo = true` allows of getting `scrollTop`.
`options.enableResizeInfo = true` allows of getting `width` and `height` of client.
`eventType` could be one of the following:

@@ -81,0 +83,0 @@

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