Socket
Socket
Sign inDemoInstall

pointer-event

Package Overview
Dependencies
0
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.1.0

4

package.json
{
"name": "pointer-event",
"version": "1.0.2",
"version": "1.1.0",
"title": "PointerEvent",

@@ -21,3 +21,3 @@ "description": "Event Controller for mouse and touch interfaces",

"jasmine-core": "^3.7.1",
"log4js": "^6.3.0",
"log4js": "^6.4.0",
"node-static-alias": "^1.1.2",

@@ -24,0 +24,0 @@ "pre-proc": "^1.0.2",

@@ -15,3 +15,3 @@ /* ================================================

*
* Copyright (c) 2021 anseki
* Copyright (c) 2022 anseki
* Licensed under the MIT license.

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

* @param {function} moveHandler - This is called with pointerXY when it moves.
* @param {?boolean} rawEvent - Capture events without `requestAnimationFrame`.
* @returns {void}

@@ -254,3 +255,3 @@ */

key: "addMoveHandler",
value: function addMoveHandler(element, moveHandler) {
value: function addMoveHandler(element, moveHandler, rawEvent) {
var that = this;

@@ -263,3 +264,3 @@

var wrappedHandler = AnimEvent.add(function (event) {
function handler(event) {
traceLog.push('<moveListener>', "type:".concat(event.type)); // [DEBUG/]

@@ -302,3 +303,5 @@

traceLog.push('</moveListener>'); // [DEBUG/]
});
}
var wrappedHandler = rawEvent ? handler : AnimEvent.add(handler);
addEventListenerWithOptions(element, 'mousemove', wrappedHandler, {

@@ -305,0 +308,0 @@ capture: false,

@@ -15,3 +15,3 @@ /* ================================================

*
* Copyright (c) 2021 anseki
* Copyright (c) 2022 anseki
* Licensed under the MIT license.

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

* @param {function} moveHandler - This is called with pointerXY when it moves.
* @param {?boolean} rawEvent - Capture events without `requestAnimationFrame`.
* @returns {void}

@@ -238,5 +239,6 @@ */

key: "addMoveHandler",
value: function addMoveHandler(element, moveHandler) {
value: function addMoveHandler(element, moveHandler, rawEvent) {
var that = this;
var wrappedHandler = AnimEvent.add(function (event) {
function handler(event) {
var pointerClass = event.type === 'mousemove' ? 'mouse' : 'touch'; // Avoid mouse events emulation

@@ -265,3 +267,5 @@

}
});
}
var wrappedHandler = rawEvent ? handler : AnimEvent.add(handler);
addEventListenerWithOptions(element, 'mousemove', wrappedHandler, {

@@ -268,0 +272,0 @@ capture: false,

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

/*! PointerEvent v1.0.2 (c) anseki https://github.com/anseki/pointer-event */
var PointerEvent=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var r,o=[],a=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return setTimeout(e,1e3/60)},i=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame||function(e){return clearTimeout(e)},u=Date.now();function l(){var e,t;r&&(i.call(window,r),r=null),o.forEach((function(t){var n;(n=t.event)&&(t.event=null,t.listener(n),e=!0)})),e?(u=Date.now(),t=!0):Date.now()-u<500&&(t=!0),t&&(r=a.call(window,l))}function c(e){var t=-1;return o.some((function(n,r){return n.listener===e&&(t=r,!0)})),t}var s={add:function(e){var t;return-1===c(e)?(o.push(t={listener:e}),function(e){t.event=e,r||l()}):null},remove:function(e){var t;(t=c(e))>-1&&(o.splice(t,1),!o.length&&r&&(i.call(window,r),r=null))}};function d(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var f=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){f=!0}}))}catch(e){}function h(e,t,n,r){e.addEventListener(t,n,f?r:r.capture)}function v(e,t){if(null!=e&&null!=t)for(var n=0;n<e.length;n++)if(e[n].identifier===t)return e[n];return null}function p(e){return e&&"number"==typeof e.clientX&&"number"==typeof e.clientY}function m(e){e.preventDefault()}var w=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.startHandlers={},this.lastHandlerId=0,this.curPointerClass=null,this.curTouchId=null,this.lastPointerXY={clientX:0,clientY:0},this.lastTouchTime=0,this.options={preventDefault:!0,stopPropagation:!0},t&&["preventDefault","stopPropagation"].forEach((function(e){"boolean"==typeof t[e]&&(n.options[e]=t[e])}))}var t,n,r;return t=e,r=[{key:"addEventListenerWithOptions",get:function(){return h}}],(n=[{key:"regStartHandler",value:function(e){var t=this;return t.startHandlers[++t.lastHandlerId]=function(n){var r,o,a="mousedown"===n.type?"mouse":"touch",i=Date.now();if("touch"===a)t.lastTouchTime=i,r=n.changedTouches[0],o=n.changedTouches[0].identifier;else{if(i-t.lastTouchTime<400)return;r=n}if(!p(r))throw new Error("No clientX/clientY");t.curPointerClass&&t.cancel(),e.call(t,r)&&(t.curPointerClass=a,t.curTouchId="touch"===a?o:null,t.lastPointerXY.clientX=r.clientX,t.lastPointerXY.clientY=r.clientY,t.options.preventDefault&&n.preventDefault(),t.options.stopPropagation&&n.stopPropagation())},t.lastHandlerId}},{key:"unregStartHandler",value:function(e){delete this.startHandlers[e]}},{key:"addStartHandler",value:function(e,t){if(!this.startHandlers[t])throw new Error("Invalid handlerId: ".concat(t));return h(e,"mousedown",this.startHandlers[t],{capture:!1,passive:!1}),h(e,"touchstart",this.startHandlers[t],{capture:!1,passive:!1}),h(e,"dragstart",m,{capture:!1,passive:!1}),t}},{key:"removeStartHandler",value:function(e,t){if(!this.startHandlers[t])throw new Error("Invalid handlerId: ".concat(t));return e.removeEventListener("mousedown",this.startHandlers[t],!1),e.removeEventListener("touchstart",this.startHandlers[t],!1),e.removeEventListener("dragstart",m,!1),t}},{key:"addMoveHandler",value:function(e,t){var n=this,r=s.add((function(e){var t="mousemove"===e.type?"mouse":"touch";if("touch"===t&&(n.lastTouchTime=Date.now()),t===n.curPointerClass){var r="touch"===t?v(e.changedTouches,n.curTouchId):e;p(r)&&(r.clientX===n.lastPointerXY.clientX&&r.clientY===n.lastPointerXY.clientY||n.move(r),n.options.preventDefault&&e.preventDefault(),n.options.stopPropagation&&e.stopPropagation())}}));h(e,"mousemove",r,{capture:!1,passive:!1}),h(e,"touchmove",r,{capture:!1,passive:!1}),n.curMoveHandler=t}},{key:"move",value:function(e){p(e)&&(this.lastPointerXY.clientX=e.clientX,this.lastPointerXY.clientY=e.clientY),this.curMoveHandler&&this.curMoveHandler(this.lastPointerXY)}},{key:"addEndHandler",value:function(e,t){var n=this;function r(e){var t="mouseup"===e.type?"mouse":"touch";if("touch"===t&&(n.lastTouchTime=Date.now()),t===n.curPointerClass){var r="touch"===t?v(e.changedTouches,n.curTouchId)||(v(e.touches,n.curTouchId)?null:{}):e;r&&(n.end(r),n.options.preventDefault&&e.preventDefault(),n.options.stopPropagation&&e.stopPropagation())}}h(e,"mouseup",r,{capture:!1,passive:!1}),h(e,"touchend",r,{capture:!1,passive:!1}),n.curEndHandler=t}},{key:"end",value:function(e){p(e)&&(this.lastPointerXY.clientX=e.clientX,this.lastPointerXY.clientY=e.clientY),this.curEndHandler&&this.curEndHandler(this.lastPointerXY),this.curPointerClass=this.curTouchId=null}},{key:"addCancelHandler",value:function(e,t){var n=this;h(e,"touchcancel",(function(e){n.lastTouchTime=Date.now(),null!=n.curPointerClass&&(v(e.changedTouches,n.curTouchId)||!v(e.touches,n.curTouchId))&&n.cancel()}),{capture:!1,passive:!1}),n.curCancelHandler=t}},{key:"cancel",value:function(){this.curCancelHandler&&this.curCancelHandler(),this.curPointerClass=this.curTouchId=null}}])&&d(t.prototype,n),r&&d(t,r),e}();t.default=w}]).default;
/*! PointerEvent v1.1.0 (c) anseki https://github.com/anseki/pointer-event */
var PointerEvent=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var r,o=[],a=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return setTimeout(e,1e3/60)},i=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame||function(e){return clearTimeout(e)},u=Date.now();function l(){var e,t;r&&(i.call(window,r),r=null),o.forEach((function(t){var n;(n=t.event)&&(t.event=null,t.listener(n),e=!0)})),e?(u=Date.now(),t=!0):Date.now()-u<500&&(t=!0),t&&(r=a.call(window,l))}function c(e){var t=-1;return o.some((function(n,r){return n.listener===e&&(t=r,!0)})),t}var s={add:function(e){var t;return-1===c(e)?(o.push(t={listener:e}),function(e){t.event=e,r||l()}):null},remove:function(e){var t;(t=c(e))>-1&&(o.splice(t,1),!o.length&&r&&(i.call(window,r),r=null))}};function d(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var f=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){f=!0}}))}catch(e){}function h(e,t,n,r){e.addEventListener(t,n,f?r:r.capture)}function v(e,t){if(null!=e&&null!=t)for(var n=0;n<e.length;n++)if(e[n].identifier===t)return e[n];return null}function p(e){return e&&"number"==typeof e.clientX&&"number"==typeof e.clientY}function m(e){e.preventDefault()}var w=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.startHandlers={},this.lastHandlerId=0,this.curPointerClass=null,this.curTouchId=null,this.lastPointerXY={clientX:0,clientY:0},this.lastTouchTime=0,this.options={preventDefault:!0,stopPropagation:!0},t&&["preventDefault","stopPropagation"].forEach((function(e){"boolean"==typeof t[e]&&(n.options[e]=t[e])}))}var t,n,r;return t=e,r=[{key:"addEventListenerWithOptions",get:function(){return h}}],(n=[{key:"regStartHandler",value:function(e){var t=this;return t.startHandlers[++t.lastHandlerId]=function(n){var r,o,a="mousedown"===n.type?"mouse":"touch",i=Date.now();if("touch"===a)t.lastTouchTime=i,r=n.changedTouches[0],o=n.changedTouches[0].identifier;else{if(i-t.lastTouchTime<400)return;r=n}if(!p(r))throw new Error("No clientX/clientY");t.curPointerClass&&t.cancel(),e.call(t,r)&&(t.curPointerClass=a,t.curTouchId="touch"===a?o:null,t.lastPointerXY.clientX=r.clientX,t.lastPointerXY.clientY=r.clientY,t.options.preventDefault&&n.preventDefault(),t.options.stopPropagation&&n.stopPropagation())},t.lastHandlerId}},{key:"unregStartHandler",value:function(e){delete this.startHandlers[e]}},{key:"addStartHandler",value:function(e,t){if(!this.startHandlers[t])throw new Error("Invalid handlerId: ".concat(t));return h(e,"mousedown",this.startHandlers[t],{capture:!1,passive:!1}),h(e,"touchstart",this.startHandlers[t],{capture:!1,passive:!1}),h(e,"dragstart",m,{capture:!1,passive:!1}),t}},{key:"removeStartHandler",value:function(e,t){if(!this.startHandlers[t])throw new Error("Invalid handlerId: ".concat(t));return e.removeEventListener("mousedown",this.startHandlers[t],!1),e.removeEventListener("touchstart",this.startHandlers[t],!1),e.removeEventListener("dragstart",m,!1),t}},{key:"addMoveHandler",value:function(e,t,n){var r=this;function o(e){var t="mousemove"===e.type?"mouse":"touch";if("touch"===t&&(r.lastTouchTime=Date.now()),t===r.curPointerClass){var n="touch"===t?v(e.changedTouches,r.curTouchId):e;p(n)&&(n.clientX===r.lastPointerXY.clientX&&n.clientY===r.lastPointerXY.clientY||r.move(n),r.options.preventDefault&&e.preventDefault(),r.options.stopPropagation&&e.stopPropagation())}}var a=n?o:s.add(o);h(e,"mousemove",a,{capture:!1,passive:!1}),h(e,"touchmove",a,{capture:!1,passive:!1}),r.curMoveHandler=t}},{key:"move",value:function(e){p(e)&&(this.lastPointerXY.clientX=e.clientX,this.lastPointerXY.clientY=e.clientY),this.curMoveHandler&&this.curMoveHandler(this.lastPointerXY)}},{key:"addEndHandler",value:function(e,t){var n=this;function r(e){var t="mouseup"===e.type?"mouse":"touch";if("touch"===t&&(n.lastTouchTime=Date.now()),t===n.curPointerClass){var r="touch"===t?v(e.changedTouches,n.curTouchId)||(v(e.touches,n.curTouchId)?null:{}):e;r&&(n.end(r),n.options.preventDefault&&e.preventDefault(),n.options.stopPropagation&&e.stopPropagation())}}h(e,"mouseup",r,{capture:!1,passive:!1}),h(e,"touchend",r,{capture:!1,passive:!1}),n.curEndHandler=t}},{key:"end",value:function(e){p(e)&&(this.lastPointerXY.clientX=e.clientX,this.lastPointerXY.clientY=e.clientY),this.curEndHandler&&this.curEndHandler(this.lastPointerXY),this.curPointerClass=this.curTouchId=null}},{key:"addCancelHandler",value:function(e,t){var n=this;h(e,"touchcancel",(function(e){n.lastTouchTime=Date.now(),null!=n.curPointerClass&&(v(e.changedTouches,n.curTouchId)||!v(e.touches,n.curTouchId))&&n.cancel()}),{capture:!1,passive:!1}),n.curCancelHandler=t}},{key:"cancel",value:function(){this.curCancelHandler&&this.curCancelHandler(),this.curPointerClass=this.curTouchId=null}}])&&d(t.prototype,n),r&&d(t,r),e}();t.default=w}]).default;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc