@ajiu9/gesture
Advanced tools
Comparing version 1.0.3-beta.7 to 1.0.3-beta.8
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{constructor(t,e){let s=!1;const i=new Map,n=document.documentElement;t.addEventListener("mousedown",(t=>{const c=Object.create(null);i.set("mouse"+(1<<t.button),c),e.start(t,c);const a=t=>{let s=1;for(;s<=t.buttons;){if(s&t.buttons){let n;n=2===s?4:4===s?2:s;const c=i.get(`mouse${n}`);e.move(t,c)}s<<=1}},r=t=>{const c=i.get("mouse"+(1<<t.button));e.end(t,c),i.delete("mouse"+(1<<t.button)),0===t.buttons&&(n.removeEventListener("mousemove",a),n.removeEventListener("mouseup",r),s=!1)};s||(n.addEventListener("mousemove",a),n.addEventListener("mouseup",r),s=!0)})),t.addEventListener("touchstart",(t=>{for(const s of t.changedTouches){const t=Object.create(null);i.set(s.identifier,t),e.start(s,t)}})),t.addEventListener("touchmove",(t=>{for(const s of t.changedTouches){const n=i.get(s.identifier);t.preventDefault(),e.move(s,n)}})),t.addEventListener("touchend",(t=>{for(const s of t.changedTouches){const t=i.get(s.identifier);e.end(s,t),i.delete(s.identifier)}})),t.addEventListener("touchcancel",(t=>{for(const s of t.changedTouches){const t=i.get(s.identifier);e.cancel(s,t),i.delete(s.identifier)}}))}}class e{constructor(t){this.dispatcher=t}start(t,e){e.startX=t.clientX,e.startY=t.clientY,this.dispatcher.dispatch("start",{clientX:t.clientX,clientY:t.clientY}),e.points=[{t:Date.now(),x:t.clientX,y:t.clientY}],e.isTap=!0,e.isPan=!1,e.isPress=!1,e.handler=setTimeout((()=>{e.isTap=!1,e.isPan=!1,e.isPress=!0,e.handler=null,this.dispatcher.dispatch("press",{})}),500)}move(t,e){const s=t.clientX-e.startX,i=t.clientY-e.startY;!e.isPan&&s**2+i**2>100&&(e.isPan=!0,e.isTap=!1,e.isPress=!1,e.isVertical=Math.abs(s)-Math.abs(i)>=0,clearTimeout(e.handler),this.dispatcher.dispatch("panStart",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical})),e.isPan&&this.dispatcher.dispatch("pan",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical}),e.points=e.points.filter((t=>Date.now()-t.t<500)),e.points.push({t:Date.now(),x:t.clientX,y:t.clientY})}end(t,e){e.isTap&&(this.dispatcher.dispatch("tap",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY}),clearTimeout(e.handler)),e.isPress&&this.dispatcher.dispatch("pressEnd",{}),e.points=e.points.filter((t=>Date.now()-t.t<500));let s=0;if(e.points.length){s=Math.sqrt((t.clientX-e.points[0].x)**2+(t.clientY-e.points[0].y)**2)/(Date.now()-e.points[0].t)}s>1.5?(e.isFlick=!0,this.dispatcher.dispatch("flick",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical,isFlick:e.isFlick,velocity:s})):e.isFlick=!1,e.isPan&&this.dispatcher.dispatch("panEnd",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical,isFlick:e.isFlick,velocity:s}),this.dispatcher.dispatch("end",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical,isFlick:e.isFlick,isPan:e.isPan,velocity:s})}cancel=(t,e)=>{clearTimeout(e.handler),this.dispatcher.dispatch("cancel",{})}}class s{constructor(t){this.element=t}dispatch(t,e){const s=new Event(t);for(const i in e)s[i]=e[i];this.element.dispatchEvent(s)}}exports.Dispatcher=s,exports.Listener=t,exports.Recognizer=e,exports.enableGesture=function(i){new t(i,new e(new s(i)))}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=Object.defineProperty,e=(e,s,i)=>(((e,s,i)=>{s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[s]=i})(e,"symbol"!=typeof s?s+"":s,i),i);class s{constructor(t,e){let s=!1;const i=new Map,n=document.documentElement;t.addEventListener("mousedown",(t=>{const c=Object.create(null);i.set("mouse"+(1<<t.button),c),e.start(t,c);const a=t=>{let s=1;for(;s<=t.buttons;){if(s&t.buttons){let n;n=2===s?4:4===s?2:s;const c=i.get(`mouse${n}`);e.move(t,c)}s<<=1}},r=t=>{const c=i.get("mouse"+(1<<t.button));e.end(t,c),i.delete("mouse"+(1<<t.button)),0===t.buttons&&(n.removeEventListener("mousemove",a),n.removeEventListener("mouseup",r),s=!1)};s||(n.addEventListener("mousemove",a),n.addEventListener("mouseup",r),s=!0)})),t.addEventListener("touchstart",(t=>{for(const s of t.changedTouches){const t=Object.create(null);i.set(s.identifier,t),e.start(s,t)}})),t.addEventListener("touchmove",(t=>{for(const s of t.changedTouches){const n=i.get(s.identifier);t.preventDefault(),e.move(s,n)}})),t.addEventListener("touchend",(t=>{for(const s of t.changedTouches){const t=i.get(s.identifier);e.end(s,t),i.delete(s.identifier)}})),t.addEventListener("touchcancel",(t=>{for(const s of t.changedTouches){const t=i.get(s.identifier);e.cancel(s,t),i.delete(s.identifier)}}))}}class i{constructor(t){e(this,"cancel",((t,e)=>{clearTimeout(e.handler),this.dispatcher.dispatch("cancel",{})})),this.dispatcher=t}start(t,e){e.startX=t.clientX,e.startY=t.clientY,this.dispatcher.dispatch("start",{clientX:t.clientX,clientY:t.clientY}),e.points=[{t:Date.now(),x:t.clientX,y:t.clientY}],e.isTap=!0,e.isPan=!1,e.isPress=!1,e.handler=setTimeout((()=>{e.isTap=!1,e.isPan=!1,e.isPress=!0,e.handler=null,this.dispatcher.dispatch("press",{})}),500)}move(t,e){const s=t.clientX-e.startX,i=t.clientY-e.startY;!e.isPan&&s**2+i**2>100&&(e.isPan=!0,e.isTap=!1,e.isPress=!1,e.isVertical=Math.abs(s)-Math.abs(i)>=0,clearTimeout(e.handler),this.dispatcher.dispatch("panStart",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical})),e.isPan&&this.dispatcher.dispatch("pan",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical}),e.points=e.points.filter((t=>Date.now()-t.t<500)),e.points.push({t:Date.now(),x:t.clientX,y:t.clientY})}end(t,e){e.isTap&&(this.dispatcher.dispatch("tap",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY}),clearTimeout(e.handler)),e.isPress&&this.dispatcher.dispatch("pressEnd",{}),e.points=e.points.filter((t=>Date.now()-t.t<500));let s=0;if(e.points.length){s=Math.sqrt((t.clientX-e.points[0].x)**2+(t.clientY-e.points[0].y)**2)/(Date.now()-e.points[0].t)}s>1.5?(e.isFlick=!0,this.dispatcher.dispatch("flick",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical,isFlick:e.isFlick,velocity:s})):e.isFlick=!1,e.isPan&&this.dispatcher.dispatch("panEnd",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical,isFlick:e.isFlick,velocity:s}),this.dispatcher.dispatch("end",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical,isFlick:e.isFlick,isPan:e.isPan,velocity:s})}}class n{constructor(t){this.element=t}dispatch(t,e){const s=new Event(t);for(const i in e)s[i]=e[i];this.element.dispatchEvent(s)}}exports.Dispatcher=n,exports.Listener=s,exports.Recognizer=i,exports.enableGesture=function(t){new s(t,new i(new n(t)))}; |
@@ -1,1 +0,1 @@ | ||
class t{constructor(t,e){let s=!1;const i=new Map,n=document.documentElement;t.addEventListener("mousedown",(t=>{const c=Object.create(null);i.set("mouse"+(1<<t.button),c),e.start(t,c);const a=t=>{let s=1;for(;s<=t.buttons;){if(s&t.buttons){let n;n=2===s?4:4===s?2:s;const c=i.get(`mouse${n}`);e.move(t,c)}s<<=1}},r=t=>{const c=i.get("mouse"+(1<<t.button));e.end(t,c),i.delete("mouse"+(1<<t.button)),0===t.buttons&&(n.removeEventListener("mousemove",a),n.removeEventListener("mouseup",r),s=!1)};s||(n.addEventListener("mousemove",a),n.addEventListener("mouseup",r),s=!0)})),t.addEventListener("touchstart",(t=>{for(const s of t.changedTouches){const t=Object.create(null);i.set(s.identifier,t),e.start(s,t)}})),t.addEventListener("touchmove",(t=>{for(const s of t.changedTouches){const n=i.get(s.identifier);t.preventDefault(),e.move(s,n)}})),t.addEventListener("touchend",(t=>{for(const s of t.changedTouches){const t=i.get(s.identifier);e.end(s,t),i.delete(s.identifier)}})),t.addEventListener("touchcancel",(t=>{for(const s of t.changedTouches){const t=i.get(s.identifier);e.cancel(s,t),i.delete(s.identifier)}}))}}class e{constructor(t){this.dispatcher=t}start(t,e){e.startX=t.clientX,e.startY=t.clientY,this.dispatcher.dispatch("start",{clientX:t.clientX,clientY:t.clientY}),e.points=[{t:Date.now(),x:t.clientX,y:t.clientY}],e.isTap=!0,e.isPan=!1,e.isPress=!1,e.handler=setTimeout((()=>{e.isTap=!1,e.isPan=!1,e.isPress=!0,e.handler=null,this.dispatcher.dispatch("press",{})}),500)}move(t,e){const s=t.clientX-e.startX,i=t.clientY-e.startY;!e.isPan&&s**2+i**2>100&&(e.isPan=!0,e.isTap=!1,e.isPress=!1,e.isVertical=Math.abs(s)-Math.abs(i)>=0,clearTimeout(e.handler),this.dispatcher.dispatch("panStart",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical})),e.isPan&&this.dispatcher.dispatch("pan",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical}),e.points=e.points.filter((t=>Date.now()-t.t<500)),e.points.push({t:Date.now(),x:t.clientX,y:t.clientY})}end(t,e){e.isTap&&(this.dispatcher.dispatch("tap",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY}),clearTimeout(e.handler)),e.isPress&&this.dispatcher.dispatch("pressEnd",{}),e.points=e.points.filter((t=>Date.now()-t.t<500));let s=0;if(e.points.length){s=Math.sqrt((t.clientX-e.points[0].x)**2+(t.clientY-e.points[0].y)**2)/(Date.now()-e.points[0].t)}s>1.5?(e.isFlick=!0,this.dispatcher.dispatch("flick",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical,isFlick:e.isFlick,velocity:s})):e.isFlick=!1,e.isPan&&this.dispatcher.dispatch("panEnd",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical,isFlick:e.isFlick,velocity:s}),this.dispatcher.dispatch("end",{startX:e.startX,startY:e.startY,clientX:t.clientX,clientY:t.clientY,isVertical:e.isVertical,isFlick:e.isFlick,isPan:e.isPan,velocity:s})}cancel=(t,e)=>{clearTimeout(e.handler),this.dispatcher.dispatch("cancel",{})}}class s{constructor(t){this.element=t}dispatch(t,e){const s=new Event(t);for(const i in e)s[i]=e[i];this.element.dispatchEvent(s)}}function i(i){new t(i,new e(new s(i)))}export{s as Dispatcher,t as Listener,e as Recognizer,i as enableGesture}; | ||
var t=Object.defineProperty,e=Math.pow,s=(e,s,i)=>(((e,s,i)=>{s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[s]=i})(e,"symbol"!=typeof s?s+"":s,i),i);class i{constructor(t,e){let s=!1;const i=new Map,n=document.documentElement;t.addEventListener("mousedown",(t=>{const c=Object.create(null);i.set("mouse"+(1<<t.button),c),e.start(t,c);const a=t=>{let s=1;for(;s<=t.buttons;){if(s&t.buttons){let n;n=2===s?4:4===s?2:s;const c=i.get(`mouse${n}`);e.move(t,c)}s<<=1}},r=t=>{const c=i.get("mouse"+(1<<t.button));e.end(t,c),i.delete("mouse"+(1<<t.button)),0===t.buttons&&(n.removeEventListener("mousemove",a),n.removeEventListener("mouseup",r),s=!1)};s||(n.addEventListener("mousemove",a),n.addEventListener("mouseup",r),s=!0)})),t.addEventListener("touchstart",(t=>{for(const s of t.changedTouches){const t=Object.create(null);i.set(s.identifier,t),e.start(s,t)}})),t.addEventListener("touchmove",(t=>{for(const s of t.changedTouches){const n=i.get(s.identifier);t.preventDefault(),e.move(s,n)}})),t.addEventListener("touchend",(t=>{for(const s of t.changedTouches){const t=i.get(s.identifier);e.end(s,t),i.delete(s.identifier)}})),t.addEventListener("touchcancel",(t=>{for(const s of t.changedTouches){const t=i.get(s.identifier);e.cancel(s,t),i.delete(s.identifier)}}))}}class n{constructor(t){s(this,"cancel",((t,e)=>{clearTimeout(e.handler),this.dispatcher.dispatch("cancel",{})})),this.dispatcher=t}start(t,e){e.startX=t.clientX,e.startY=t.clientY,this.dispatcher.dispatch("start",{clientX:t.clientX,clientY:t.clientY}),e.points=[{t:Date.now(),x:t.clientX,y:t.clientY}],e.isTap=!0,e.isPan=!1,e.isPress=!1,e.handler=setTimeout((()=>{e.isTap=!1,e.isPan=!1,e.isPress=!0,e.handler=null,this.dispatcher.dispatch("press",{})}),500)}move(t,s){const i=t.clientX-s.startX,n=t.clientY-s.startY;!s.isPan&&e(i,2)+e(n,2)>100&&(s.isPan=!0,s.isTap=!1,s.isPress=!1,s.isVertical=Math.abs(i)-Math.abs(n)>=0,clearTimeout(s.handler),this.dispatcher.dispatch("panStart",{startX:s.startX,startY:s.startY,clientX:t.clientX,clientY:t.clientY,isVertical:s.isVertical})),s.isPan&&this.dispatcher.dispatch("pan",{startX:s.startX,startY:s.startY,clientX:t.clientX,clientY:t.clientY,isVertical:s.isVertical}),s.points=s.points.filter((t=>Date.now()-t.t<500)),s.points.push({t:Date.now(),x:t.clientX,y:t.clientY})}end(t,s){s.isTap&&(this.dispatcher.dispatch("tap",{startX:s.startX,startY:s.startY,clientX:t.clientX,clientY:t.clientY}),clearTimeout(s.handler)),s.isPress&&this.dispatcher.dispatch("pressEnd",{}),s.points=s.points.filter((t=>Date.now()-t.t<500));let i=0;if(s.points.length){i=Math.sqrt(e(t.clientX-s.points[0].x,2)+e(t.clientY-s.points[0].y,2))/(Date.now()-s.points[0].t)}i>1.5?(s.isFlick=!0,this.dispatcher.dispatch("flick",{startX:s.startX,startY:s.startY,clientX:t.clientX,clientY:t.clientY,isVertical:s.isVertical,isFlick:s.isFlick,velocity:i})):s.isFlick=!1,s.isPan&&this.dispatcher.dispatch("panEnd",{startX:s.startX,startY:s.startY,clientX:t.clientX,clientY:t.clientY,isVertical:s.isVertical,isFlick:s.isFlick,velocity:i}),this.dispatcher.dispatch("end",{startX:s.startX,startY:s.startY,clientX:t.clientX,clientY:t.clientY,isVertical:s.isVertical,isFlick:s.isFlick,isPan:s.isPan,velocity:i})}}class c{constructor(t){this.element=t}dispatch(t,e){const s=new Event(t);for(const i in e)s[i]=e[i];this.element.dispatchEvent(s)}}function a(t){new i(t,new n(new c(t)))}export{c as Dispatcher,i as Listener,n as Recognizer,a as enableGesture}; |
{ | ||
"name": "@ajiu9/gesture", | ||
"version": "1.0.3-beta.7", | ||
"version": "1.0.3-beta.8", | ||
"description": "", | ||
@@ -22,3 +22,11 @@ "author": "ajiu9 <615944323@qq.com> (https://github.com/ajiu9/)", | ||
"dist" | ||
] | ||
], | ||
"buildOptions": { | ||
"name": "Gesture", | ||
"formats": [ | ||
"esm-bundler", | ||
"cjs", | ||
"global" | ||
] | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12251
7
44
0