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

@seregpie/claw

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@seregpie/claw - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

2

Claw.js

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

(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Claw=b()})(this,function(){"use strict";function a(a){return void 0===a}function b(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function c(a){for(var c in a)if(b(a,c))return!1;return!0}function d(a,b){var c={};return Object.entries(a).forEach(function(a){var d=a[0],e=a[1];c[d]=b(e)}),c}function e(){}function f(a,b,c,d){var e=Math.hypot;return e(c-a,d-b)}var g={_onMouseDown:e,_onMouseMove:e,_onMouseUp:e,_onTouchEnd:e,_onTouchMove:e,_onTouchStart:e},h=function(a){var b={};return a.forEach(function(a){var c=a[0],d=a[1];b[c]=d}),b}(["MouseDown","MouseMove","MouseUp","TouchEnd","TouchMove","TouchStart"].map(function(a){return[a.toLowerCase(),function(b){this["_on"+a](b)}]})),i=function(){function b(a,b){var c=this;void 0===b&&(b={});var e=b.distanceThreshold;void 0===e&&(e=1);var f=b.timeThreshold;void 0===f&&(f=500),this.target=a,Object.assign(this,{distanceThreshold:e,timeThreshold:f}),this._resetState(),this._listeners={};var g=d(h,function(a){return a.bind(c)}),i=g.mousedown,j=g.mousemove,k=g.mouseup,l=g.touchend,m=g.touchmove,n=g.touchstart;this._targetListeners={mousedown:i,touchend:l,touchmove:m,touchstart:n},this._windowListeners={mousemove:j,mouseup:k}}var e={isIdle:{configurable:!0}};return b.prototype._bindNativeListeners=function(){var a=this;Object.entries(this._targetListeners).forEach(function(b){var c=b[0],d=b[1];a.target.addEventListener(c,d)}),Object.entries(this._windowListeners).forEach(function(a){var b=a[0],c=a[1];window.addEventListener(b,c)})},b.prototype._unbindNativeListeners=function(){var a=this;Object.entries(this._targetListeners).forEach(function(b){var c=b[0],d=b[1];a.target.removeEventListener(c,d)}),Object.entries(this._windowListeners).forEach(function(a){var b=a[0],c=a[1];window.removeEventListener(b,c)})},b.prototype.on=function(a,b){this.isIdle&&this._bindNativeListeners(),a=a.toLowerCase();var c=this._listeners[a];return c||(this._listeners[a]=c=[]),c.push(b),this},b.prototype.off=function(b,c){if(a(b))this._listeners={};else if(b=b.toLowerCase(),a(c))delete this._listeners[b];else{var d=this._listeners[b];if(d){var e=d.indexOf(c);0<=e&&(d.splice(e,1),!d.length&&delete this._listeners[b])}}return this.isIdle&&this._unbindNativeListeners(),this},b.prototype.trigger=function(a,b){a=a.toLowerCase();var c=this._listeners[a];return c&&c.forEach(function(a){a(b)}),this},e.isIdle.get=function(){return c(this._listeners)},b.prototype._setState=function(a){this._state=Object.assign({},g,a)},b.prototype._resetState=function(){var a,b=this,c=function(c){var d=Date.now(),e=c.x,g=c.y,h=setTimeout(function(){var c=Date.now();b.trigger("hold",{initialTimeStamp:d,pointerType:a,timeStamp:c,x:e,y:g}),b._resetState()},b.timeThreshold),i=function(c){var i=Date.now(),j=c.x,k=c.y;if(f(e,g,j,k)>=b.distanceThreshold){clearTimeout(h),b.trigger("panStart",{initialTimeStamp:d,initialX:e,initialY:g,pointerType:a,timeStamp:i,x:j,y:k});var l=d,m=e,n=g;b.trigger("pan",{initialTimeStamp:d,initialX:e,initialY:g,pointerType:a,previousTimeStamp:l,previousX:m,previousY:n,timeStamp:i,x:j,y:k});var o=function(c){l=i,m=j,n=k,i=Date.now(),j=c.x,k=c.y,b.trigger("pan",{initialTimeStamp:d,initialX:e,initialY:g,pointerType:a,previousTimeStamp:l,previousX:m,previousY:n,timeStamp:i,x:j,y:k})},p=function(){var c=Date.now();b.trigger("panEnd",{initialTimeStamp:d,initialX:e,initialY:g,pointerType:a,timeStamp:c,x:j,y:k}),b._resetState()},q={};switch(a){case"touch":{Object.assign(q,{_onTouchMove:function(a){if(1===a.touches.length){a.preventDefault();var b=a.touches[0].clientX,c=a.touches[0].clientY;o({x:b,y:c})}},_onTouchEnd:function(a){1===a.changedTouches.length&&(a.preventDefault(),p())}});break}case"mouse":{Object.assign(q,{_onMouseMove:function(a){a.preventDefault();var b=a.clientX,c=a.clientY;o({x:b,y:c})},_onMouseUp:function(a){1===a.which&&(a.preventDefault(),p())}});break}}b._setState(q)}},j=function(){var c=Date.now();b.trigger("tap",{initialTimeStamp:d,pointerType:a,timeStamp:c,x:e,y:g}),clearTimeout(h),b._resetState()},k={};switch(a){case"touch":{Object.assign(k,{_onTouchMove:function(a){if(1===a.touches.length){a.preventDefault();var b=a.touches[0].clientX,c=a.touches[0].clientY;i({x:b,y:c})}},_onTouchEnd:function(a){1===a.changedTouches.length&&(a.preventDefault(),j())}});break}case"mouse":{Object.assign(k,{_onMouseMove:function(a){a.preventDefault();var b=a.clientX,c=a.clientY;i({x:b,y:c})},_onMouseUp:function(a){1===a.which&&(a.preventDefault(),j())}});break}}b._setState(k)};this._setState({_onTouchStart:function(b){if(a="touch",1===b.touches.length){b.preventDefault();var d=b.touches[0].clientX,e=b.touches[0].clientY;c({x:d,y:e})}},_onMouseDown:function(b){if(a="mouse",1===b.which){b.preventDefault();var d=b.clientX,e=b.clientY;c({x:d,y:e})}}})},Object.defineProperties(b.prototype,e),b}();return Object.keys(g).forEach(function(a){Object.defineProperty(i.prototype,a,{get:function(){return this._state[a]}})}),i});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.Claw=n()}(this,function(){"use strict";function e(t){return void 0===t}function t(){}var o={t:t,n:t,o:t,i:t,e:t,u:t};function l(t,n,o,i){return Math.hypot(o-t,i-n)}var d={mousedown:function(t){this.t(t)},mousemove:function(t){this.n(t)},mouseup:function(t){this.o(t)},touchend:function(t){this.i(t)},touchmove:function(t){this.e(t)},touchstart:function(t){this.u(t)}},n=function(){function t(t,n){var o=this;void 0===n&&(n={});var i=n.delay;void 0===i&&(i=500);var e=n.distance;void 0===e&&(e=1),this.target=t,Object.assign(this,{delay:i,distance:e}),this.c(),this.r={};var u,c,r,s=(u=d,c=function(t){return t.bind(o)},r={},Object.entries(u).forEach(function(t){var n=t[0],o=t[1];r[n]=c(o)}),r),a=s.mousedown,h=s.mousemove,f=s.mouseup,v=s.touchend,m=s.touchmove,p=s.touchstart;this.s={mousedown:a,touchend:v,touchmove:m,touchstart:p},this.a={mousemove:h,mouseup:f}}var n={isIdle:{configurable:!0}};return t.prototype.h=function(){var i=this;Object.entries(this.s).forEach(function(t){var n=t[0],o=t[1];i.target.addEventListener(n,o)}),Object.entries(this.a).forEach(function(t){var n=t[0],o=t[1];window.addEventListener(n,o)})},t.prototype.f=function(){var i=this;Object.entries(this.s).forEach(function(t){var n=t[0],o=t[1];i.target.removeEventListener(n,o)}),Object.entries(this.a).forEach(function(t){var n=t[0],o=t[1];window.removeEventListener(n,o)})},t.prototype.on=function(t,n){this.isIdle&&this.h(),t=t.toLowerCase();var o=this.r[t];return o||(this.r[t]=o=[]),o.push(n),this},t.prototype.off=function(t,n){if(e(t))this.r={};else if(t=t.toLowerCase(),e(n))delete this.r[t];else{var o=this.r[t];if(o){var i=o.indexOf(n);0<=i&&(o.splice(i,1),o.length||delete this.r[t])}}return this.isIdle&&this.f(),this},t.prototype.trigger=function(t,n){t=t.toLowerCase();var o=this.r[t];return o&&o.forEach(function(t){t(n)}),this},n.isIdle.get=function(){return function(t){for(var n in t)if(o=t,i=n,Object.prototype.hasOwnProperty.call(o,i))return!1;var o,i;return!0}(this.r)},t.prototype.v=function(t){this.m=Object.assign({},o,t)},t.prototype.c=function(){var f,v,m,p,n,d=this,T=function(n){return function(t){t.preventDefault(),0<t.touches.length&&(m=t.touches[0].clientX,p=t.touches[0].clientY),n()}},_=function(n){return function(t){t.preventDefault(),m=t.clientX,p=t.clientY,n()}},b=function(n){return function(t){1===t.which&&_(n)(t)}},t=function(){v=Date.now();var s=m,a=p,h=setTimeout(function(){v=Date.now(),d.trigger("holdStart",{pointerType:f,timeStamp:v,x:s,y:a});var t=v,n=function(){v=Date.now(),d.trigger("holdEnd",{initialTimeStamp:t,pointerType:f,timeStamp:v,x:s,y:a}),d.c()},o=function(){l(s,a,m,p)>=d.distance&&n()},i={};switch(f){case"touch":Object.assign(i,{u:T(n),e:T(o),i:T(n)});break;case"mouse":Object.assign(i,{n:_(o),o:b(n)})}d.v(i)},d.delay),t=function(){if(v=Date.now(),l(s,a,m,p)>=d.distance){clearTimeout(h),d.trigger("panStart",{pointerType:f,timeStamp:v,x:s,y:a});var t=v,n=t,o=s,i=a,e=function(){d.trigger("pan",{initialTimeStamp:t,initialX:s,initialY:a,pointerType:f,previousTimeStamp:n,previousX:o,previousY:i,timeStamp:v,x:m,y:p})};e();var u=function(){v=Date.now(),e(),n=v,o=m,i=p},c=function(){v=Date.now(),d.trigger("panEnd",{initialTimeStamp:t,initialX:s,initialY:a,pointerType:f,timeStamp:v,x:m,y:p}),d.c()},r={};switch(f){case"touch":Object.assign(r,{u:T(c),e:T(u),i:T(c)});break;case"mouse":Object.assign(r,{n:_(u),o:b(c)})}d.v(r)}},n=function(){clearTimeout(h),v=Date.now(),d.trigger("tap",{pointerType:f,timeStamp:v,x:m,y:p}),d.c()},o={};switch(f){case"touch":Object.assign(o,{u:T(function(){clearTimeout(h),d.c()}),e:T(t),i:T(n)});break;case"mouse":Object.assign(o,{n:_(t),o:b(n)})}d.v(o)};this.v({u:(n=function(){f="touch",t()},function(t){1===t.touches.length&&T(n)(t)}),t:b(function(){f="mouse",t()})})},Object.defineProperties(t.prototype,n),t}();return Object.keys(o).forEach(function(t){Object.defineProperty(n.prototype,t,{get:function(){return this.m[t]}})}),n});
{
"name": "@seregpie/claw",
"version": "2.0.0",
"version": "3.0.0",
"description": "A very small gesture recognizer.",

@@ -27,7 +27,7 @@ "keywords": [

"devDependencies": {
"@seregpie/rollup-plugin-resolve": "^18.6.13",
"rollup": "^0.66.6",
"rollup-plugin-babel-minify": "^6.1.1",
"rollup-plugin-buble": "^0.19.4"
"@seregpie/rollup-plugin-resolve": "^18.7.0",
"rollup": "^0.67.3",
"rollup-plugin-buble": "^0.19.4",
"rollup-plugin-uglify": "^6.0.0"
}
}

@@ -33,4 +33,4 @@ # Claw

.constructor(target, {
distanceThreshold = 1,
timeThreshold = 500,
delay = 500,
distance = 1,
})

@@ -42,4 +42,4 @@ ```

| `target` | The target element. |
| `distanceThreshold` | The distance to separate the event types. |
| `timeThreshold` | The time to separate the event types. |
| `delay` | The delay threshold to separate the event types. |
| `distance` | The distance threshold to separate the event types. |

@@ -100,7 +100,6 @@ ```javascript

`hold`
`holdStart`
```js
{
initialTimeStamp,
pointerType,

@@ -115,3 +114,3 @@ timeStamp,

`pan`
`holdEnd`

@@ -121,8 +120,3 @@ ```js

initialTimeStamp,
initialX,
initialY,
pointerType,
previousTimeStamp,
previousX,
previousY,
timeStamp,

@@ -140,2 +134,15 @@ x,

{
pointerType,
timeStamp,
x,
y,
}
```
---
`pan`
```js
{
initialTimeStamp,

@@ -145,2 +152,5 @@ initialX,

pointerType,
previousTimeStamp,
previousX,
previousY,
timeStamp,

@@ -174,3 +184,2 @@ x,

{
initialTimeStamp,
pointerType,

@@ -177,0 +186,0 @@ timeStamp,

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