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

event-from

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-from - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

72

dist/event-from.cjs.development.js

@@ -10,7 +10,3 @@ 'use strict';

var recentFocusFrom = recentEventFrom;
var recentWindowFocus = false; // if detect-it believes the deviceType is touchOnly then it is
// highly unlikely that there is a mouse (but not impossible),
// so wait extra long for mouse events after touch input before attributing them to mouse input
var recentTouchEventTimerMultiple = detectIt.deviceType === 'touchOnly' ? 3 : 1; // To determine if there was a recentTouch event
var recentWindowFocus = false; // To determine if there was a recentTouch event
// use setTimeout instead of a Date.now() comparison because

@@ -34,3 +30,6 @@ // in the case of a long running/blocking process from a touch event,

var setRecentTouchTimeout = function (delay) {
var setRecentEventFromTouch = function (touchDelay) {
recentTouch = true;
recentEventFrom = 'touch';
if (recentTouchTimeoutId !== undefined) {

@@ -43,10 +42,11 @@ window.clearTimeout(recentTouchTimeoutId);

recentTouchTimeoutId = undefined;
}, delay * recentTouchEventTimerMultiple);
}, // if detect-it believes the deviceType is touchOnly
// then it is highly unlikely that there is a mouse (but not impossible),
// so wait 3*delay for mouse events after touch input before attributing them to mouse input
touchDelay * (detectIt.deviceType === 'touchOnly' ? 3 : 1));
};
var setRecentTouch = function (delay) {
var handleTouchEvent = function (touchDelay) {
return function () {
recentTouch = true;
recentEventFrom = 'touch';
setRecentTouchTimeout(delay);
return setRecentEventFromTouch(touchDelay);
};

@@ -64,3 +64,3 @@ };

case 'touch':
setRecentTouch(touchDelay)();
setRecentEventFromTouch(touchDelay);
break;

@@ -78,9 +78,10 @@ }

recentEventFrom = 'key';
};
}; // recentFocusFrom tracking
// set document focus event capture listener which sets recentFocusFrom equal to recentEventFrom
// except if there is a recent window focus event where the window is the target,
// in which case leave recentFocusFrom unchanged to maintain correct recentFocusFrom after switching apps/windows/tabs/etc,
// if/when the focus event is passed into eventFrom later in the cycle, just return recentFocusFrom.
// for tracking recent window focus, set window focus capture event listener,
// if the target is window (or document on firefox), then track recentWindowFocus with setTimeout 300
var handleDocumentFocusEvent = function () {
if (!recentWindowFocus) {
recentFocusFrom = recentEventFrom;
}
};

@@ -100,2 +101,15 @@ var recentWindowFocusTimeoutId;

var handleWindowFocusEvent = function (e) {
if (e.target === window || e.target === document) {
recentWindowFocus = true;
setRecentWindowFocusTimeout();
}
};
var handleDocumentFocusEvent = function () {
if (!recentWindowFocus) {
recentFocusFrom = recentEventFrom;
}
};
var listenerOptions = detectIt.supportsPassiveEvents ? {

@@ -105,3 +119,3 @@ capture: true,

} : true;
var documentListeners = [['touchstart', /*#__PURE__*/setRecentTouch(750)], ['touchend', /*#__PURE__*/setRecentTouch(300)], ['touchcancel', /*#__PURE__*/setRecentTouch(300)], ['pointerover', /*#__PURE__*/handlePointerEvent(300)], ['pointerenter', /*#__PURE__*/handlePointerEvent(300)], ['pointerdown', /*#__PURE__*/handlePointerEvent(750)], ['pointerout', /*#__PURE__*/handlePointerEvent(300)], ['pointerleave', /*#__PURE__*/handlePointerEvent(300)], ['pointerup', /*#__PURE__*/handlePointerEvent(300)], ['mouseenter', handleMouseEvent], ['mousedown', handleMouseEvent], ['mouseleave', handleMouseEvent], ['mouseup', handleMouseEvent], ['keydown', handleKeyEvent], ['keyup', handleKeyEvent], ['focus', handleDocumentFocusEvent]];
var documentListeners = [['touchstart', /*#__PURE__*/handleTouchEvent(750)], ['touchend', /*#__PURE__*/handleTouchEvent(300)], ['touchcancel', /*#__PURE__*/handleTouchEvent(300)], ['pointerover', /*#__PURE__*/handlePointerEvent(300)], ['pointerenter', /*#__PURE__*/handlePointerEvent(300)], ['pointerdown', /*#__PURE__*/handlePointerEvent(750)], ['pointerout', /*#__PURE__*/handlePointerEvent(300)], ['pointerleave', /*#__PURE__*/handlePointerEvent(300)], ['pointerup', /*#__PURE__*/handlePointerEvent(300)], ['mouseenter', handleMouseEvent], ['mousedown', handleMouseEvent], ['mouseleave', handleMouseEvent], ['mouseup', handleMouseEvent], ['keydown', handleKeyEvent], ['keyup', handleKeyEvent], ['focus', handleDocumentFocusEvent]];

@@ -116,8 +130,3 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {

});
window.addEventListener('focus', function (e) {
if (e.target === window || e.target === document) {
recentWindowFocus = true;
setRecentWindowFocusTimeout();
}
}, listenerOptions);
window.addEventListener('focus', handleWindowFocusEvent, listenerOptions);
}

@@ -138,7 +147,7 @@

if (!recentTouch) {
setRecentTouchTimeout(300);
recentTouch = true;
setRecentEventFromTouch(300);
} else {
recentEventFrom = 'touch';
}
recentEventFrom = 'touch';
break;

@@ -153,7 +162,6 @@ }

if (!recentTouch) {
setRecentTouchTimeout(300);
recentTouch = true;
setRecentEventFromTouch(300);
} else {
recentEventFrom = 'touch';
}
recentEventFrom = 'touch';
}

@@ -160,0 +168,0 @@

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,o=require("detect-it"),n=o.primaryInput,u=!1,i=n,c=!1,s="touchOnly"===o.deviceType?3:1,r=function(t){void 0!==e&&window.clearTimeout(e),e=window.setTimeout((function(){u=!1,e=void 0}),t*s)},d=function(e){return function(){u=!0,n="touch",r(e)}},p=function(e){return function(t){switch(t.pointerType){case"mouse":n="mouse";break;case"pen":case"touch":d(e)()}}},a=function(){u||(n="mouse")},f=function(){n="key"},m=!o.supportsPassiveEvents||{capture:!0,passive:!0};"undefined"!=typeof window&&"undefined"!=typeof document&&([["touchstart",d(750)],["touchend",d(300)],["touchcancel",d(300)],["pointerover",p(300)],["pointerenter",p(300)],["pointerdown",p(750)],["pointerout",p(300)],["pointerleave",p(300)],["pointerup",p(300)],["mouseenter",a],["mousedown",a],["mouseleave",a],["mouseup",a],["keydown",f],["keyup",f],["focus",function(){c||(i=n)}]].forEach((function(e){var t=e[0],o=e[1];document.addEventListener(t,o,m)})),window.addEventListener("focus",(function(e){e.target!==window&&e.target!==document||(c=!0,void 0!==t&&window.clearTimeout(t),t=window.setTimeout((function(){c=!1,t=void 0}),300))}),m));exports.eventFrom=function(e){switch(e.pointerType){case"mouse":n="mouse";break;case"pen":case"touch":u||(r(300),u=!0),n="touch"}return/mouse/.test(e.type)&&!u&&(n="mouse"),/touch/.test(e.type)&&(u||(r(300),u=!0),n="touch"),/focus/.test(e.type)?i:n};//# sourceMappingURL=event-from.cjs.production.js.map
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,o=require("detect-it"),n=o.primaryInput,u=!1,i=n,c=!1,r=function(t){u=!0,n="touch",void 0!==e&&window.clearTimeout(e),e=window.setTimeout((function(){u=!1,e=void 0}),t*("touchOnly"===o.deviceType?3:1))},s=function(e){return function(){return r(e)}},d=function(e){return function(t){switch(t.pointerType){case"mouse":n="mouse";break;case"pen":case"touch":r(e)}}},p=function(){u||(n="mouse")},a=function(){n="key"},f=!o.supportsPassiveEvents||{capture:!0,passive:!0};"undefined"!=typeof window&&"undefined"!=typeof document&&([["touchstart",s(750)],["touchend",s(300)],["touchcancel",s(300)],["pointerover",d(300)],["pointerenter",d(300)],["pointerdown",d(750)],["pointerout",d(300)],["pointerleave",d(300)],["pointerup",d(300)],["mouseenter",p],["mousedown",p],["mouseleave",p],["mouseup",p],["keydown",a],["keyup",a],["focus",function(){c||(i=n)}]].forEach((function(e){var t=e[0],o=e[1];document.addEventListener(t,o,f)})),window.addEventListener("focus",(function(e){e.target!==window&&e.target!==document||(c=!0,void 0!==t&&window.clearTimeout(t),t=window.setTimeout((function(){c=!1,t=void 0}),300))}),f));exports.eventFrom=function(e){switch(e.pointerType){case"mouse":n="mouse";break;case"pen":case"touch":u?n="touch":r(300)}return/mouse/.test(e.type)&&!u&&(n="mouse"),/touch/.test(e.type)&&(u?n="touch":r(300)),/focus/.test(e.type)?i:n};//# sourceMappingURL=event-from.cjs.production.js.map

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

import { primaryInput, supportsPassiveEvents, deviceType } from 'detect-it';
import { primaryInput, deviceType, supportsPassiveEvents } from 'detect-it';

@@ -6,7 +6,3 @@ var recentEventFrom = primaryInput;

var recentFocusFrom = recentEventFrom;
var recentWindowFocus = false; // if detect-it believes the deviceType is touchOnly then it is
// highly unlikely that there is a mouse (but not impossible),
// so wait extra long for mouse events after touch input before attributing them to mouse input
var recentTouchEventTimerMultiple = deviceType === 'touchOnly' ? 3 : 1; // To determine if there was a recentTouch event
var recentWindowFocus = false; // To determine if there was a recentTouch event
// use setTimeout instead of a Date.now() comparison because

@@ -30,3 +26,6 @@ // in the case of a long running/blocking process from a touch event,

var setRecentTouchTimeout = function (delay) {
var setRecentEventFromTouch = function (touchDelay) {
recentTouch = true;
recentEventFrom = 'touch';
if (recentTouchTimeoutId !== undefined) {

@@ -39,10 +38,11 @@ window.clearTimeout(recentTouchTimeoutId);

recentTouchTimeoutId = undefined;
}, delay * recentTouchEventTimerMultiple);
}, // if detect-it believes the deviceType is touchOnly
// then it is highly unlikely that there is a mouse (but not impossible),
// so wait 3*delay for mouse events after touch input before attributing them to mouse input
touchDelay * (deviceType === 'touchOnly' ? 3 : 1));
};
var setRecentTouch = function (delay) {
var handleTouchEvent = function (touchDelay) {
return function () {
recentTouch = true;
recentEventFrom = 'touch';
setRecentTouchTimeout(delay);
return setRecentEventFromTouch(touchDelay);
};

@@ -60,3 +60,3 @@ };

case 'touch':
setRecentTouch(touchDelay)();
setRecentEventFromTouch(touchDelay);
break;

@@ -74,9 +74,10 @@ }

recentEventFrom = 'key';
};
}; // recentFocusFrom tracking
// set document focus event capture listener which sets recentFocusFrom equal to recentEventFrom
// except if there is a recent window focus event where the window is the target,
// in which case leave recentFocusFrom unchanged to maintain correct recentFocusFrom after switching apps/windows/tabs/etc,
// if/when the focus event is passed into eventFrom later in the cycle, just return recentFocusFrom.
// for tracking recent window focus, set window focus capture event listener,
// if the target is window (or document on firefox), then track recentWindowFocus with setTimeout 300
var handleDocumentFocusEvent = function () {
if (!recentWindowFocus) {
recentFocusFrom = recentEventFrom;
}
};

@@ -96,2 +97,15 @@ var recentWindowFocusTimeoutId;

var handleWindowFocusEvent = function (e) {
if (e.target === window || e.target === document) {
recentWindowFocus = true;
setRecentWindowFocusTimeout();
}
};
var handleDocumentFocusEvent = function () {
if (!recentWindowFocus) {
recentFocusFrom = recentEventFrom;
}
};
var listenerOptions = supportsPassiveEvents ? {

@@ -101,3 +115,3 @@ capture: true,

} : true;
var documentListeners = [['touchstart', /*#__PURE__*/setRecentTouch(750)], ['touchend', /*#__PURE__*/setRecentTouch(300)], ['touchcancel', /*#__PURE__*/setRecentTouch(300)], ['pointerover', /*#__PURE__*/handlePointerEvent(300)], ['pointerenter', /*#__PURE__*/handlePointerEvent(300)], ['pointerdown', /*#__PURE__*/handlePointerEvent(750)], ['pointerout', /*#__PURE__*/handlePointerEvent(300)], ['pointerleave', /*#__PURE__*/handlePointerEvent(300)], ['pointerup', /*#__PURE__*/handlePointerEvent(300)], ['mouseenter', handleMouseEvent], ['mousedown', handleMouseEvent], ['mouseleave', handleMouseEvent], ['mouseup', handleMouseEvent], ['keydown', handleKeyEvent], ['keyup', handleKeyEvent], ['focus', handleDocumentFocusEvent]];
var documentListeners = [['touchstart', /*#__PURE__*/handleTouchEvent(750)], ['touchend', /*#__PURE__*/handleTouchEvent(300)], ['touchcancel', /*#__PURE__*/handleTouchEvent(300)], ['pointerover', /*#__PURE__*/handlePointerEvent(300)], ['pointerenter', /*#__PURE__*/handlePointerEvent(300)], ['pointerdown', /*#__PURE__*/handlePointerEvent(750)], ['pointerout', /*#__PURE__*/handlePointerEvent(300)], ['pointerleave', /*#__PURE__*/handlePointerEvent(300)], ['pointerup', /*#__PURE__*/handlePointerEvent(300)], ['mouseenter', handleMouseEvent], ['mousedown', handleMouseEvent], ['mouseleave', handleMouseEvent], ['mouseup', handleMouseEvent], ['keydown', handleKeyEvent], ['keyup', handleKeyEvent], ['focus', handleDocumentFocusEvent]];

@@ -112,8 +126,3 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {

});
window.addEventListener('focus', function (e) {
if (e.target === window || e.target === document) {
recentWindowFocus = true;
setRecentWindowFocusTimeout();
}
}, listenerOptions);
window.addEventListener('focus', handleWindowFocusEvent, listenerOptions);
}

@@ -134,7 +143,7 @@

if (!recentTouch) {
setRecentTouchTimeout(300);
recentTouch = true;
setRecentEventFromTouch(300);
} else {
recentEventFrom = 'touch';
}
recentEventFrom = 'touch';
break;

@@ -149,7 +158,6 @@ }

if (!recentTouch) {
setRecentTouchTimeout(300);
recentTouch = true;
setRecentEventFromTouch(300);
} else {
recentEventFrom = 'touch';
}
recentEventFrom = 'touch';
}

@@ -156,0 +164,0 @@

@@ -89,7 +89,3 @@ (function (global, factory) {

var recentFocusFrom = recentEventFrom;
var recentWindowFocus = false; // if detect-it believes the deviceType is touchOnly then it is
// highly unlikely that there is a mouse (but not impossible),
// so wait extra long for mouse events after touch input before attributing them to mouse input
var recentTouchEventTimerMultiple = deviceType === 'touchOnly' ? 3 : 1; // To determine if there was a recentTouch event
var recentWindowFocus = false; // To determine if there was a recentTouch event
// use setTimeout instead of a Date.now() comparison because

@@ -113,3 +109,6 @@ // in the case of a long running/blocking process from a touch event,

var setRecentTouchTimeout = function (delay) {
var setRecentEventFromTouch = function (touchDelay) {
recentTouch = true;
recentEventFrom = 'touch';
if (recentTouchTimeoutId !== undefined) {

@@ -122,10 +121,11 @@ window.clearTimeout(recentTouchTimeoutId);

recentTouchTimeoutId = undefined;
}, delay * recentTouchEventTimerMultiple);
}, // if detect-it believes the deviceType is touchOnly
// then it is highly unlikely that there is a mouse (but not impossible),
// so wait 3*delay for mouse events after touch input before attributing them to mouse input
touchDelay * (deviceType === 'touchOnly' ? 3 : 1));
};
var setRecentTouch = function (delay) {
var handleTouchEvent = function (touchDelay) {
return function () {
recentTouch = true;
recentEventFrom = 'touch';
setRecentTouchTimeout(delay);
return setRecentEventFromTouch(touchDelay);
};

@@ -143,3 +143,3 @@ };

case 'touch':
setRecentTouch(touchDelay)();
setRecentEventFromTouch(touchDelay);
break;

@@ -157,9 +157,10 @@ }

recentEventFrom = 'key';
};
}; // recentFocusFrom tracking
// set document focus event capture listener which sets recentFocusFrom equal to recentEventFrom
// except if there is a recent window focus event where the window is the target,
// in which case leave recentFocusFrom unchanged to maintain correct recentFocusFrom after switching apps/windows/tabs/etc,
// if/when the focus event is passed into eventFrom later in the cycle, just return recentFocusFrom.
// for tracking recent window focus, set window focus capture event listener,
// if the target is window (or document on firefox), then track recentWindowFocus with setTimeout 300
var handleDocumentFocusEvent = function () {
if (!recentWindowFocus) {
recentFocusFrom = recentEventFrom;
}
};

@@ -179,2 +180,15 @@ var recentWindowFocusTimeoutId;

var handleWindowFocusEvent = function (e) {
if (e.target === window || e.target === document) {
recentWindowFocus = true;
setRecentWindowFocusTimeout();
}
};
var handleDocumentFocusEvent = function () {
if (!recentWindowFocus) {
recentFocusFrom = recentEventFrom;
}
};
var listenerOptions = supportsPassiveEvents ? {

@@ -184,3 +198,3 @@ capture: true,

} : true;
var documentListeners = [['touchstart', /*#__PURE__*/setRecentTouch(750)], ['touchend', /*#__PURE__*/setRecentTouch(300)], ['touchcancel', /*#__PURE__*/setRecentTouch(300)], ['pointerover', /*#__PURE__*/handlePointerEvent(300)], ['pointerenter', /*#__PURE__*/handlePointerEvent(300)], ['pointerdown', /*#__PURE__*/handlePointerEvent(750)], ['pointerout', /*#__PURE__*/handlePointerEvent(300)], ['pointerleave', /*#__PURE__*/handlePointerEvent(300)], ['pointerup', /*#__PURE__*/handlePointerEvent(300)], ['mouseenter', handleMouseEvent], ['mousedown', handleMouseEvent], ['mouseleave', handleMouseEvent], ['mouseup', handleMouseEvent], ['keydown', handleKeyEvent], ['keyup', handleKeyEvent], ['focus', handleDocumentFocusEvent]];
var documentListeners = [['touchstart', /*#__PURE__*/handleTouchEvent(750)], ['touchend', /*#__PURE__*/handleTouchEvent(300)], ['touchcancel', /*#__PURE__*/handleTouchEvent(300)], ['pointerover', /*#__PURE__*/handlePointerEvent(300)], ['pointerenter', /*#__PURE__*/handlePointerEvent(300)], ['pointerdown', /*#__PURE__*/handlePointerEvent(750)], ['pointerout', /*#__PURE__*/handlePointerEvent(300)], ['pointerleave', /*#__PURE__*/handlePointerEvent(300)], ['pointerup', /*#__PURE__*/handlePointerEvent(300)], ['mouseenter', handleMouseEvent], ['mousedown', handleMouseEvent], ['mouseleave', handleMouseEvent], ['mouseup', handleMouseEvent], ['keydown', handleKeyEvent], ['keyup', handleKeyEvent], ['focus', handleDocumentFocusEvent]];

@@ -195,8 +209,3 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {

});
window.addEventListener('focus', function (e) {
if (e.target === window || e.target === document) {
recentWindowFocus = true;
setRecentWindowFocusTimeout();
}
}, listenerOptions);
window.addEventListener('focus', handleWindowFocusEvent, listenerOptions);
}

@@ -217,7 +226,7 @@

if (!recentTouch) {
setRecentTouchTimeout(300);
recentTouch = true;
setRecentEventFromTouch(300);
} else {
recentEventFrom = 'touch';
}
recentEventFrom = 'touch';
break;

@@ -232,7 +241,6 @@ }

if (!recentTouch) {
setRecentTouchTimeout(300);
recentTouch = true;
setRecentEventFromTouch(300);
} else {
recentEventFrom = 'touch';
}
recentEventFrom = 'touch';
}

@@ -239,0 +247,0 @@

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).EventFrom={})}(this,(function(e){"use strict";var t="undefined"!=typeof window?window:{screen:{},navigator:{}},n=t.matchMedia||function(){return{matches:!1}},o=!1,i={get passive(){return o=!0}},u=function(){};t.addEventListener&&t.addEventListener("p",u,i),t.removeEventListener&&t.removeEventListener("p",u,!1);var c,s,r=o,a="ontouchstart"in t,d=a||"TouchEvent"in t&&n("(any-pointer: coarse)").matches,f=(t.navigator.maxTouchPoints||0)>0||d,p=t.navigator.userAgent||"",h=n("(pointer: coarse)").matches&&/iPad|Macintosh/.test(p)&&Math.min(t.screen.width||0,t.screen.height||0)>=768,m=(n("(pointer: coarse)").matches||!n("(pointer: fine)").matches&&a)&&!/Windows.*Firefox/.test(p),v=n("(any-pointer: fine)").matches||n("(any-hover: hover)").matches||h||!a,w=!f||!v&&m?f?"touchOnly":"mouseOnly":"hybrid",y="mouseOnly"===w?"mouse":"touchOnly"===w||m?"touch":"mouse",l=!1,g=y,T=!1,E="touchOnly"===w?3:1,b=function(e){void 0!==c&&window.clearTimeout(c),c=window.setTimeout((function(){l=!1,c=void 0}),e*E)},L=function(e){return function(){l=!0,y="touch",b(e)}},O=function(e){return function(t){switch(t.pointerType){case"mouse":y="mouse";break;case"pen":case"touch":L(e)()}}},k=function(){l||(y="mouse")},x=function(){y="key"},M=!r||{capture:!0,passive:!0};"undefined"!=typeof window&&"undefined"!=typeof document&&([["touchstart",L(750)],["touchend",L(300)],["touchcancel",L(300)],["pointerover",O(300)],["pointerenter",O(300)],["pointerdown",O(750)],["pointerout",O(300)],["pointerleave",O(300)],["pointerup",O(300)],["mouseenter",k],["mousedown",k],["mouseleave",k],["mouseup",k],["keydown",x],["keyup",x],["focus",function(){T||(g=y)}]].forEach((function(e){var t=e[0],n=e[1];document.addEventListener(t,n,M)})),window.addEventListener("focus",(function(e){e.target!==window&&e.target!==document||(T=!0,void 0!==s&&window.clearTimeout(s),s=window.setTimeout((function(){T=!1,s=void 0}),300))}),M));e.eventFrom=function(e){switch(e.pointerType){case"mouse":y="mouse";break;case"pen":case"touch":l||(b(300),l=!0),y="touch"}return/mouse/.test(e.type)&&!l&&(y="mouse"),/touch/.test(e.type)&&(l||(b(300),l=!0),y="touch"),/focus/.test(e.type)?g:y},Object.defineProperty(e,"__esModule",{value:!0})}));//# sourceMappingURL=event-from.umd.production.js.map
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).EventFrom={})}(this,(function(e){"use strict";var t="undefined"!=typeof window?window:{screen:{},navigator:{}},n=t.matchMedia||function(){return{matches:!1}},o=!1,i={get passive(){return o=!0}},u=function(){};t.addEventListener&&t.addEventListener("p",u,i),t.removeEventListener&&t.removeEventListener("p",u,!1);var c,s,r=o,a="ontouchstart"in t,d=a||"TouchEvent"in t&&n("(any-pointer: coarse)").matches,f=(t.navigator.maxTouchPoints||0)>0||d,p=t.navigator.userAgent||"",h=n("(pointer: coarse)").matches&&/iPad|Macintosh/.test(p)&&Math.min(t.screen.width||0,t.screen.height||0)>=768,m=(n("(pointer: coarse)").matches||!n("(pointer: fine)").matches&&a)&&!/Windows.*Firefox/.test(p),v=n("(any-pointer: fine)").matches||n("(any-hover: hover)").matches||h||!a,w=!f||!v&&m?f?"touchOnly":"mouseOnly":"hybrid",y="mouseOnly"===w?"mouse":"touchOnly"===w||m?"touch":"mouse",l=!1,g=y,T=!1,E=function(e){l=!0,y="touch",void 0!==c&&window.clearTimeout(c),c=window.setTimeout((function(){l=!1,c=void 0}),e*("touchOnly"===w?3:1))},b=function(e){return function(){return E(e)}},L=function(e){return function(t){switch(t.pointerType){case"mouse":y="mouse";break;case"pen":case"touch":E(e)}}},O=function(){l||(y="mouse")},k=function(){y="key"},x=!r||{capture:!0,passive:!0};"undefined"!=typeof window&&"undefined"!=typeof document&&([["touchstart",b(750)],["touchend",b(300)],["touchcancel",b(300)],["pointerover",L(300)],["pointerenter",L(300)],["pointerdown",L(750)],["pointerout",L(300)],["pointerleave",L(300)],["pointerup",L(300)],["mouseenter",O],["mousedown",O],["mouseleave",O],["mouseup",O],["keydown",k],["keyup",k],["focus",function(){T||(g=y)}]].forEach((function(e){var t=e[0],n=e[1];document.addEventListener(t,n,x)})),window.addEventListener("focus",(function(e){e.target!==window&&e.target!==document||(T=!0,void 0!==s&&window.clearTimeout(s),s=window.setTimeout((function(){T=!1,s=void 0}),300))}),x));e.eventFrom=function(e){switch(e.pointerType){case"mouse":y="mouse";break;case"pen":case"touch":l?y="touch":E(300)}return/mouse/.test(e.type)&&!l&&(y="mouse"),/touch/.test(e.type)&&(l?y="touch":E(300)),/focus/.test(e.type)?g:y},Object.defineProperty(e,"__esModule",{value:!0})}));//# sourceMappingURL=event-from.umd.production.js.map
{
"name": "event-from",
"version": "0.2.0",
"version": "0.2.1",
"description": "Determine if an event was caused by mouse, touch or key input.",

@@ -5,0 +5,0 @@ "main": "dist/event-from.cjs.js",

@@ -96,4 +96,4 @@ # Event From

Event From sets passive event listeners on the `document` and `window` and tracks the recent event history to know what input type is responsible for the event that's passed to `eventFrom(event)`.
Event From sets passive capture phase event listeners on the `document` and `window` and tracks the recent event history to know what input type is responsible for the event that's passed to `eventFrom(event)`.
The listeners that Event From sets are all low frequency event listeners (enter/leave/down/up/focus/etc). Event From does not set any high frequency listeners such as `move` or `scroll` listeners.

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