pointeract 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,32 +5,35 @@
5
5
  <br>
6
6
  </h1>
7
7
 
8
- <h4 align="center"> Modern, lightweight, robust and extensible user interaction resolver </h4>
8
+ <h4 align="center"> 🖱️🤏 lightweight, robust and extensible human gesture detector </h4>
9
9
 
10
10
  <p align="center">
11
- <a href="https://github.com/hesprs/pointeract/actions">
12
- <img src="https://img.shields.io/github/actions/workflow/status/hesprs/pointeract/ci-test.yml?style=flat&logo=github&logoColor=white&label=CI&labelColor=d4ab00&color=333333" alt="CI Status" />
13
- </a>
14
- <a href="https://codecov.io/github/hesprs/pointeract">
15
- <img src="https://img.shields.io/codecov/c/github/hesprs/pointeract/main?style=flat&logo=codecov&logoColor=white&label=Test%20Coverage&labelColor=ff0077&color=333333" alt="Test Coverage" />
16
- </a>
17
- <a href="https://www.codefactor.io/repository/github/hesprs/pointeract">
18
- <img src="https://img.shields.io/codefactor/grade/github/hesprs/pointeract?style=flat&logo=codefactor&logoColor=white&label=Code%20Quality&labelColor=17b37a&color=333333" alt="Code Quality" />
19
- </a>
20
- <a href="https://pointeract.consensia.cc">
21
- <img src="https://img.shields.io/badge/Documentation-Ready-333333?labelColor=5C73E7&logo=vitepress&logoColor=white" alt="Documentation" />
22
- </a>
23
- <a href="https://www.npmjs.com/package/pointeract">
24
- <img src="https://img.shields.io/npm/v/pointeract?logo=npm&labelColor=red&logoColor=white&color=333333" alt="npm package" />
25
- </a>
26
- <a href="https://snyk.io/test/npm/pointeract">
27
- <img src="https://img.shields.io/badge/Snyk%20Security-Monitored-333333?logo=snyk&style=flat&labelColor=8A2BE2&logoColor=white" alt="library security" />
28
- </a>
29
- <a href="https://bundlephobia.com/package/pointeract">
30
- <img src="https://img.shields.io/bundlejs/size/pointeract?format=minzip&style=flat&logo=webpack&logoColor=white&label=Minzipped%20Size&labelColor=orange&color=333333" alt="package size" />
31
- </a>
32
- <img src="https://img.shields.io/badge/Types-Strict-333333?logo=typescript&labelColor=blue&logoColor=white" alt="Typescript" />
33
- <img src="https://img.shields.io/badge/%F0%9F%96%90%EF%B8%8F%20Made%20by-Humans-333333?labelColor=25C260" alt="Made by Humans" />
11
+ <a href="https://github.com/hesprs/pointeract/actions">
12
+ <img src="https://img.shields.io/github/actions/workflow/status/hesprs/pointeract/ci-test.yml?style=flat&logo=github&logoColor=white&label=CI&labelColor=d4ab00&color=333333" alt="CI Status" />
13
+ </a>
14
+ <a href="https://codecov.io/github/hesprs/pointeract">
15
+ <img src="https://img.shields.io/codecov/c/github/hesprs/pointeract/main?style=flat&logo=codecov&logoColor=white&label=Test%20Coverage&labelColor=ff0077&color=333333" alt="Test Coverage" />
16
+ </a>
17
+ <a href="https://www.codefactor.io/repository/github/hesprs/pointeract">
18
+ <img src="https://img.shields.io/codefactor/grade/github/hesprs/pointeract?style=flat&logo=codefactor&logoColor=white&label=Code%20Quality&labelColor=17b37a&color=333333" alt="Code Quality" />
19
+ </a>
20
+ <a href="https://pointeract.consensia.cc">
21
+ <img src="https://img.shields.io/badge/Documentation-Ready-333333?labelColor=5C73E7&logo=vitepress&logoColor=white" alt="Documentation" />
22
+ </a>
23
+ <a href="https://www.npmjs.com/package/pointeract">
24
+ <img src="https://img.shields.io/npm/v/pointeract?logo=npm&labelColor=red&logoColor=white&color=333333" alt="npm package" />
25
+ </a>
26
+ <a href="https://jsr.io/@hesprs/pointeract">
27
+ <img src="https://img.shields.io/jsr/v/@hesprs/pointeract?logo=jsr&labelColor=f7df1e&logoColor=white&color=333333" alt="JSR package" />
28
+ </a>
29
+ <a href="https://snyk.io/test/npm/pointeract">
30
+ <img src="https://img.shields.io/badge/Snyk%20Security-Monitored-333333?logo=snyk&style=flat&labelColor=8A2BE2&logoColor=white" alt="library security" />
31
+ </a>
32
+ <a href="https://bundlephobia.com/package/pointeract">
33
+ <img src="https://img.shields.io/bundlejs/size/pointeract?format=minzip&style=flat&logo=webpack&logoColor=white&label=Minzipped%20Size&labelColor=orange&color=333333" alt="package size" />
34
+ </a>
35
+ <img src="https://img.shields.io/badge/Types-Strict-333333?logo=typescript&labelColor=blue&logoColor=white" alt="Typescript" />
36
+ <img src="https://img.shields.io/badge/%F0%9F%96%90%EF%B8%8F%20Made%20by-Humans-333333?labelColor=25C260" alt="Made by Humans" />
34
37
  </p>
35
38
 
36
39
  <p align="center">
@@ -49,7 +52,7 @@
49
52
 
50
53
  Pointeract is a tiny JavaScript/TypeScript utility library focusing on one thing - handling user interactions with DOM elements, e.g. multitouch and touchpad.
51
54
 
52
- With the unique strength of versatile typings in TypeScript and its dynamic nature, Pointeract have achieved a highly _modular, extendable and efficient_ architecture. Its core bundle size is only **1KB** minified + gzipped, functionalities come from also byte-sized modules. It's fully **tree-shakable**, the fewer modules you use, the smaller your bundle is.
55
+ With the unique strength of versatile typings in TypeScript and its dynamic nature, Pointeract has achieved a highly _modular, extendable and efficient_ architecture. Its core bundle size is only **1KB** minified + gzipped, functionalities come from also byte-sized modules. It's fully **tree-shakable**, the fewer modules you use, the smaller your bundle is.
53
56
 
54
57
  ## Advantages
55
58
 
@@ -65,40 +68,37 @@ Install Pointeract using your favorite package manager:
65
68
 
66
69
  ```sh
67
70
  # npm
68
- $ npm add pointeract
71
+ npm add pointeract
69
72
 
70
73
  # pnpm
71
- $ pnpm add pointeract
74
+ pnpm add pointeract
72
75
 
73
76
  # yarn
74
- $ yarn add pointeract
77
+ yarn add pointeract
75
78
 
76
79
  # bun
77
- $ bun add pointeract
80
+ bun add pointeract
81
+
82
+ # deno
83
+ deno add jsr:@hesprs/pointeract
78
84
  ```
79
85
 
80
86
  Or include the following lines directly in your HTML file:
81
87
 
82
88
  ```html
83
89
  <script type="module">
84
- import { Pointeract } from 'https://unpkg.com/pointeract/dist/index.js';
90
+ import { Pointeract } from 'https://unpkg.com/pointeract';
85
91
  </script>
86
92
  ```
87
93
 
88
- This link ships the latest ESM version by default, to access CJS version or earlier versions, try using a different URL like:
89
-
90
- ```html
91
- <script src="https://unpkg.com/pointeract@1.0.1/dist/index.cjs"></script>
92
- ```
93
-
94
- The link above ships version 1.0.1 in CJS.
94
+ This link ships the latest ESM version by default.
95
95
 
96
96
  Then simply grab the core class and a module:
97
97
 
98
98
  ```TypeScript
99
99
  import { Pointeract, Drag } from 'pointeract';
100
100
 
101
- new Pointeract({ element: yourElement }, Drag)
101
+ new Pointeract({ element: yourElement }, [Drag])
102
102
  .start()
103
103
  .on('drag', e => console.log(e));
104
104
  ```
@@ -128,15 +128,15 @@ There're already plenty of interaction libraries out there, most famous ones are
128
128
  | :--------------------------------------------------------------------------------------- | :---------------------------------------------------: | :----------------------------------------------: | :-------------------------------------------------: |
129
129
  | Written in TypeScript? | ✅ | ❌ | ✅ |
130
130
  | Tree-shakeable? | [✅](https://bundlephobia.com/package/pointeract) | [❌](https://bundlephobia.com/package/hammerjs) | [❌](https://bundlephobia.com/package/interactjs) |
131
- | Bundle Size (Minified + Gzipped) | 👑 [3KB](https://bundlephobia.com/package/pointeract) | [7KB](https://bundlephobia.com/package/hammerjs) | [28KB](https://bundlephobia.com/package/interactjs) |
131
+ | Total Bundle Size (Minified + Gzipped) | 👑 [3KB](https://bundlephobia.com/package/pointeract) | [7KB](https://bundlephobia.com/package/hammerjs) | [28KB](https://bundlephobia.com/package/interactjs) |
132
132
  | Last Updated | 👑 Actively Maintained | 2015 | 2023 |
133
- | Features | Pointer and Wheel Related | Pointer Related | 👑 Pointer and Wheel Related + Comprehensive Utils |
133
+ | Features | Pointer and Wheel Related + Some Utils | Pointer Related | 👑 Pointer and Wheel Related + Comprehensive Utils |
134
134
  | Robust? (See [Testing](https://pointeract.consensia.cc/development/testing#monkey-test)) | ✅ | ❌ Element Jerks | ❌ Element Ignores the Second Touch |
135
135
  | Extensible? | ✅ | ❌ | ❌ |
136
136
 
137
137
  ## Get Involved
138
138
 
139
- This project welcomes anyone that have ideas to improve it.
139
+ This project welcomes anyone that has ideas to improve it.
140
140
 
141
141
  - [Open a pull request](https://github.com/hesprs/pointeract/compare) for a new module, event standard, documentation update, and so on.
142
142
  - [Open an issue](https://github.com/hesprs/pointeract/issues/new) if you find a bug.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- class t{constructor(t,e,i,s,o){this.window=e,this.pointers=i,this.element=s,this.getNthPointer=t.getNthPointer,this.toTargetCoords=t.toTargetCoords,this.augment=t.augment,this.dispatch=t.dispatch,this.options=o}getNthPointer;toTargetCoords;augment;dispatch;options;onPointerDown;onPointerUp;onPointerMove;onWheel;onStart;onStop;dispose;modifiers}function e(t,e=0){return t[t.length-1-e]}function i(t){return Array.isArray(t)?t:[t]}class s extends t{#t=-1/0;#e=0;onPointerDown=(t,e,i)=>{if(2===i.size){this.getNthPointer(0).interrupted=!0,e.interrupted=!0}};onPointerUp=(t,i)=>{if(i.interrupted)return;const s=this.options.moveThreshold??5;if(Math.abs(i.records[0].x-t.clientX)>=s||Math.abs(i.records[0].y-t.clientY)>=s)return;const o=e(i.records).timestamp,n=this.options.clickPreserveTime??400;o-this.#t<=n?this.#e++:this.#e=1,this.#t=o;const r=this.toTargetCoords({x:t.clientX,y:t.clientY});this.dispatch("trueClick",{...r,target:i.target,streak:this.#e})}}class o extends t{onPointerMove=(t,i,s)=>{const o=e(i.records,1);if(1===s.size){const e=t.clientX-o.x,i=t.clientY-o.y;this.dispatch("drag",{deltaX:e,deltaY:i,x:t.clientX,y:t.clientY})}}}class n extends t{#i={lastDistance:0,lastMidpoint:{x:0,y:0}};#s(){const t=e(this.getNthPointer(0).records),i=e(this.getNthPointer(1).records),s=t.x-i.x,o=t.y-i.y;return Math.sqrt(s*s+o*o)}#o(){const t=e(this.getNthPointer(0).records),i=e(this.getNthPointer(1).records);return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}onPointerDown=(t,e,i)=>{2===i.size&&(this.#i.lastDistance=this.#s(),this.#i.lastMidpoint=this.toTargetCoords(this.#o()))};onPointerMove=(t,e,i)=>{if(2===i.size){const t=this.#s(),e=this.#o(),i=t/this.#i.lastDistance;this.#i.lastDistance=t;const s=this.toTargetCoords(e),o=s.x-this.#i.lastMidpoint.x,n=s.y-this.#i.lastMidpoint.y;this.#i.lastMidpoint=s,this.#n({deltaX:o,deltaY:n}),this.#r(i,s)}};#r(t,e){this.dispatch("zoom",{x:e.x,y:e.y,factor:t})}#n(t){this.dispatch("pan",t)}}class r extends t{onWheel=t=>t.preventDefault();#a=t=>t.preventDefault();onStart=()=>{this.element.style.touchAction="none",this.element.addEventListener("gesturestart",this.#a,{passive:!1}),this.element.addEventListener("gesturechange",this.#a,{passive:!1})};onStop=()=>{this.element.style.touchAction="",this.element.removeEventListener("gesturestart",this.#a),this.element.removeEventListener("gesturechange",this.#a)};dispose=this.onStop}class a extends t{constructor(...t){super(...t),function(t,e){for(const[i,s]of Object.entries(t))i in e||(e[i]=s)}({proControlSchema:!1,zoomFactor:.1,lockControlSchema:!1},this.options)}onWheel=t=>{const e=this.options;if(e.proControlSchema||e.lockControlSchema||!(t.ctrlKey||t.shiftKey||Math.abs(t.deltaX)>Math.abs(t.deltaY))||(e.proControlSchema=!0),e.proControlSchema)if(t.ctrlKey){const i=1-e.zoomFactor*t.deltaY,s=this.toTargetCoords({x:t.clientX,y:t.clientY});this.#r(i,s)}else t.shiftKey&&Math.abs(t.deltaX)<=Math.abs(t.deltaY)?this.#n({deltaX:-t.deltaY,deltaY:-t.deltaX}):this.#n({deltaX:-t.deltaX,deltaY:-t.deltaY});else{const i=1-e.zoomFactor/20*t.deltaY,s=this.toTargetCoords({x:t.clientX,y:t.clientY});this.#r(i,s)}};#r(t,e){this.dispatch("zoom",{x:e.x,y:e.y,factor:t})}#n(t){this.dispatch("pan",t)}}class h extends t{#h={};#c=null;constructor(...t){super(...t);const e=this.options.lubricator;e&&Object.entries(e).forEach(([t,e])=>{const i={sample:{},fields:{}};Object.keys(e.fields).forEach(t=>{i.fields[t]={catch:1,release:1}}),this.#h[t]=i,this.modifiers[t]=this.#d(i,e)})}onStart=()=>{this.#c=requestAnimationFrame(this.#l)};onStop=()=>{this.#c&&cancelAnimationFrame(this.#c),this.#c=null,Object.values(this.#h).forEach(t=>{Object.values(t.fields).forEach(t=>{t.release=1,t.catch=1})})};#d=(t,e)=>i=>!!i.lubricated||(t.sample=i,this.#p(t.fields,e.fields,i),!1);#p=(t,e,i)=>{Object.entries(t).forEach(([t,s])=>{if("number"!=typeof i[t])return;const o=e[t].countType;"sum"===o?s.catch+=i[t]:"product"===o&&(s.catch*=i[t])})};#l=()=>{const t=this.#h,e=this.options.lubricator;e&&(Object.entries(t).forEach(([t,i])=>{const s=i.sample;s.lubricated=!0;let o=!1;for(const[n,r]of Object.entries(i.fields)){if(1===r.catch)continue;const i=e[t].fields[n].countType;let a,h,c;("sum"===i?(h=r.catch-r.release,a=Math.abs(h)):(h=r.catch/r.release,a=this.#u(h)-1),a<=e[t].fields[n].diminishBoundary)?(o||(o=!0),s[n]=h,r.release=1,r.catch=1):("sum"===i?(c=h*e[t].decayFactor,r.release+=c):(c=Math.pow(h,e[t].decayFactor),r.release*=c),s[n]=c,o=!0)}o&&this.dispatch(t,s)}),this.#c=requestAnimationFrame(this.#l))};#u=t=>t>1?t:1/t;modifiers={}}const c={decayFactor:.25,fields:{deltaX:{countType:"sum",diminishBoundary:.5},deltaY:{countType:"sum",diminishBoundary:.5}}},d=c,l={decayFactor:.25,fields:{factor:{countType:"product",diminishBoundary:.01}}};class p{#m;#f=/* @__PURE__ */new Map;#v={};#w={};#g;#y={};options;get#P(){if(!this.#g)throw new Error("[Pointeract] Window is not defined.");return this.#g}constructor(t,e){const s=i(e||[]);this.#g=t.element.ownerDocument.defaultView,this.#m=t.element,t.coordinateOutput||(t.coordinateOutput="relative"),this.options=t,s.forEach(e=>{const i=new e(this.moduleUtils,this.#P,this.#f,this.#m,this.options);Object.assign(i,{options:t}),this.#v[e.name]=i})}on=(t,e)=>(this.#y[t]||(this.#y[t]=/* @__PURE__ */new Set),this.#y[t]?.add(e),this);off(t,e){return this.#y[t]?.delete(e),this}moduleUtils={getNthPointer:t=>{const e=new Error("[Pointeract] Invalid pointer index.");if(t<0||t>=this.#f.size)throw e;let i=0;for(const s of this.#f.values()){if(i===t)return s;i++}throw e},toTargetCoords:t=>{if("absolute"===this.options.coordinateOutput)return t;const e=this.#m.getBoundingClientRect();return t.x-=e.left,t.y-=e.top,"relative"===this.options.coordinateOutput||(t.x/=e.width,t.y/=e.height),t},dispatch:(...t)=>{const e=t[0],i=t[1];let s,o=!0;for(const n of Object.values(this.#v))if(n.modifiers&&e in n.modifiers&&(o=void 0===i?n.modifiers[e]():n.modifiers[e](i),!1===o))return;s=!0===o?i:o,this.#y[e]?.forEach(t=>t(s))},augment:t=>{Object.entries(t).forEach(([t,e])=>this[t]=e)}};dispatch=this.moduleUtils.dispatch;#b(t,...e){Object.values(this.#v).forEach(i=>{const s=i[t];s&&s(...e)})}#E=t=>{if(this.#f.size>=2)return;t.isPrimary&&this.#f.clear();const e={records:[{x:t.clientX,y:t.clientY,timestamp:Date.now()}],target:t.target};this.#f.set(t.pointerId,e),this.#b("onPointerDown",t,e,this.#f)};#S=t=>{const e=this.#f.get(t.pointerId);e&&(e.records.push({x:t.clientX,y:t.clientY,timestamp:Date.now()}),this.#b("onPointerMove",t,e,this.#f))};#x=t=>{const e=this.#f.get(t.pointerId);e&&(this.#f.delete(t.pointerId),this.#b("onPointerUp",t,e,this.#f))};#M=t=>this.#b("onWheel",t);stop=t=>{const e=t=>{if(!(t.name in this.#v))return;const e=this.#v[t.name];e.onStop&&e.onStop(),this.#w[t.name]=e,delete this.#v[t.name]};return t?i(t).forEach(t=>{e(t)}):(()=>{this.#m.removeEventListener("pointerdown",this.#E),this.#P.removeEventListener("pointermove",this.#S),this.#P.removeEventListener("pointerup",this.#x),this.#m.removeEventListener("wheel",this.#M),this.#b("onStop")})(),this};start=t=>{const e=t=>{if(!(t.name in this.#w))return;const e=this.#w[t.name];e.onStart&&e.onStart(),this.#v[t.name]=e,delete this.#w[t.name]};return t?i(t).forEach(t=>{e(t)}):(()=>{this.#m.addEventListener("pointerdown",this.#E),this.#P.addEventListener("pointermove",this.#S),this.#P.addEventListener("pointerup",this.#x),this.#m.addEventListener("wheel",this.#M,{passive:!1}),this.#b("onStart")})(),this};dispose=()=>{this.stop(),this.#g=null,this.#b("dispose"),this.#y={}}}export{t as BaseModule,s as Click,o as Drag,h as Lubricator,n as MultitouchPanZoom,p as Pointeract,r as PreventDefault,a as WheelPanZoom,d as dragPreset,c as panPreset,l as zoomPreset};
1
+ class t{constructor(t,e,i,s,o){this.window=e,this.pointers=i,this.element=s,this.getNthPointer=t.getNthPointer,this.toTargetCoords=t.toTargetCoords,this.augment=t.augment,this.dispatch=t.dispatch,this.options=o}getNthPointer;toTargetCoords;augment;dispatch;options;onPointerDown;onPointerUp;onPointerMove;onWheel;onStart;onStop;dispose;modifiers}function e(t,e=0){return t[t.length-1-e]}class i extends t{#t=-1/0;#e=0;onPointerDown=(t,e,i)=>{if(2===i.size){this.getNthPointer(0).interrupted=!0,e.interrupted=!0}};onPointerUp=(t,i)=>{if(i.interrupted)return;const s=this.options.moveThreshold??5;if(Math.abs(i.records[0].x-t.clientX)>=s||Math.abs(i.records[0].y-t.clientY)>=s)return;const o=e(i.records).timestamp,n=this.options.clickPreserveTime??400;o-this.#t<=n?this.#e++:this.#e=1,this.#t=o;const r=this.toTargetCoords({x:t.clientX,y:t.clientY});this.dispatch("trueClick",{...r,target:i.target,streak:this.#e})}}class s extends t{onPointerMove=(t,i,s)=>{const o=e(i.records,1);if(1===s.size){const e=t.clientX-o.x,i=t.clientY-o.y;this.dispatch("drag",{deltaX:e,deltaY:i,x:t.clientX,y:t.clientY})}}}class o extends t{#i={lastDistance:0,lastMidpoint:{x:0,y:0}};#s(){const t=e(this.getNthPointer(0).records),i=e(this.getNthPointer(1).records),s=t.x-i.x,o=t.y-i.y;return Math.sqrt(s*s+o*o)}#o(){const t=e(this.getNthPointer(0).records),i=e(this.getNthPointer(1).records);return{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}onPointerDown=(t,e,i)=>{2===i.size&&(this.#i.lastDistance=this.#s(),this.#i.lastMidpoint=this.toTargetCoords(this.#o()))};onPointerMove=(t,e,i)=>{if(2===i.size){const t=this.#s(),e=this.#o(),i=t/this.#i.lastDistance;this.#i.lastDistance=t;const s=this.toTargetCoords(e),o=s.x-this.#i.lastMidpoint.x,n=s.y-this.#i.lastMidpoint.y;this.#i.lastMidpoint=s,this.#n({deltaX:o,deltaY:n}),this.#r(i,s)}};#r(t,e){this.dispatch("zoom",{x:e.x,y:e.y,factor:t})}#n(t){this.dispatch("pan",t)}}class n extends t{onWheel=t=>t.preventDefault();#a=t=>t.preventDefault();onStart=()=>{this.element.style.touchAction="none",this.element.addEventListener("gesturestart",this.#a,{passive:!1}),this.element.addEventListener("gesturechange",this.#a,{passive:!1})};onStop=()=>{this.element.style.touchAction="",this.element.removeEventListener("gesturestart",this.#a),this.element.removeEventListener("gesturechange",this.#a)};dispose=this.onStop}class r extends t{constructor(...t){super(...t),function(t,e){for(const[i,s]of Object.entries(t))i in e||(e[i]=s)}({proControlSchema:!1,zoomFactor:.1,lockControlSchema:!1},this.options)}onWheel=t=>{const e=this.options;if(e.proControlSchema||e.lockControlSchema||!(t.ctrlKey||t.shiftKey||Math.abs(t.deltaX)>Math.abs(t.deltaY))||(e.proControlSchema=!0),e.proControlSchema)if(t.ctrlKey){const i=1-e.zoomFactor*t.deltaY,s=this.toTargetCoords({x:t.clientX,y:t.clientY});this.#r(i,s)}else t.shiftKey&&Math.abs(t.deltaX)<=Math.abs(t.deltaY)?this.#n({deltaX:-t.deltaY,deltaY:-t.deltaX}):this.#n({deltaX:-t.deltaX,deltaY:-t.deltaY});else{const i=1-e.zoomFactor/20*t.deltaY,s=this.toTargetCoords({x:t.clientX,y:t.clientY});this.#r(i,s)}};#r(t,e){this.dispatch("zoom",{x:e.x,y:e.y,factor:t})}#n(t){this.dispatch("pan",t)}}class a extends t{#h={};#c=null;constructor(...t){super(...t);const e=this.options.lubricator;e&&Object.entries(e).forEach(([t,e])=>{const i={sample:{},fields:{}};Object.keys(e.fields).forEach(t=>{i.fields[t]={catch:1,release:1}}),this.#h[t]=i,this.modifiers[t]=this.#d(i,e)})}onStart=()=>{this.#c=requestAnimationFrame(this.#l)};onStop=()=>{this.#c&&cancelAnimationFrame(this.#c),this.#c=null,Object.values(this.#h).forEach(t=>{Object.values(t.fields).forEach(t=>{t.release=1,t.catch=1})})};#d=(t,e)=>i=>!!i.lubricated||(t.sample=i,this.#p(t.fields,e.fields,i),!1);#p=(t,e,i)=>{Object.entries(t).forEach(([t,s])=>{if("number"!=typeof i[t])return;const o=e[t].countType;"sum"===o?s.catch+=i[t]:"product"===o&&(s.catch*=i[t])})};#l=()=>{const t=this.#h,e=this.options.lubricator;e&&(Object.entries(t).forEach(([t,i])=>{const s=i.sample;s.lubricated=!0;let o=!1;for(const[n,r]of Object.entries(i.fields)){if(1===r.catch)continue;const i=e[t].fields[n].countType;let a,h,c;("sum"===i?(h=r.catch-r.release,a=Math.abs(h)):(h=r.catch/r.release,a=this.#u(h)-1),a<=e[t].fields[n].diminishBoundary)?(o||(o=!0),s[n]=h,r.release=1,r.catch=1):("sum"===i?(c=h*e[t].decayFactor,r.release+=c):(c=Math.pow(h,e[t].decayFactor),r.release*=c),s[n]=c,o=!0)}o&&this.dispatch(t,s)}),this.#c=requestAnimationFrame(this.#l))};#u=t=>t>1?t:1/t;modifiers={}}const h={decayFactor:.25,fields:{deltaX:{countType:"sum",diminishBoundary:.5},deltaY:{countType:"sum",diminishBoundary:.5}}},c=h,d={decayFactor:.25,fields:{factor:{countType:"product",diminishBoundary:.01}}};class l{#m;#f=/* @__PURE__ */new Map;#v={};#w={};#g;#P={};options;get#y(){if(!this.#g)throw new Error("[Pointeract] Window is not defined.");return this.#g}constructor(t,e){const i=e||[];this.#g=t.element.ownerDocument.defaultView,this.#m=t.element,t.coordinateOutput||(t.coordinateOutput="relative"),this.options=t,i.forEach(e=>{const i=new e(this.moduleUtils,this.#y,this.#f,this.#m,this.options);Object.assign(i,{options:t}),this.#v[e.name]=i})}on=(t,e)=>(this.#P[t]||(this.#P[t]=/* @__PURE__ */new Set),this.#P[t]?.add(e),this);off(t,e){return this.#P[t]?.delete(e),this}moduleUtils={getNthPointer:t=>{const e=new Error("[Pointeract] Invalid pointer index.");if(t<0||t>=this.#f.size)throw e;let i=0;for(const s of this.#f.values()){if(i===t)return s;i++}throw e},toTargetCoords:t=>{if("absolute"===this.options.coordinateOutput)return t;const e=this.#m.getBoundingClientRect();return t.x-=e.left,t.y-=e.top,"relative"===this.options.coordinateOutput||(t.x/=e.width,t.y/=e.height),t},dispatch:(...t)=>{const e=t[0],i=t[1];let s,o=!0;for(const n of Object.values(this.#v))if(n.modifiers&&e in n.modifiers&&(o=void 0===i?n.modifiers[e]():n.modifiers[e](i),!1===o))return;s=!0===o?i:o,this.#P[e]?.forEach(t=>t(s))},augment:t=>{Object.entries(t).forEach(([t,e])=>this[t]=e)}};dispatch=this.moduleUtils.dispatch;#b(t,...e){Object.values(this.#v).forEach(i=>{const s=i[t];s&&s(...e)})}#E=t=>{if(this.#f.size>=2)return;t.isPrimary&&this.#f.clear();const e={records:[{x:t.clientX,y:t.clientY,timestamp:Date.now()}],target:t.target};this.#f.set(t.pointerId,e),this.#b("onPointerDown",t,e,this.#f)};#S=t=>{const e=this.#f.get(t.pointerId);e&&(e.records.push({x:t.clientX,y:t.clientY,timestamp:Date.now()}),this.#b("onPointerMove",t,e,this.#f))};#x=t=>{const e=this.#f.get(t.pointerId);e&&(this.#f.delete(t.pointerId),this.#b("onPointerUp",t,e,this.#f))};#M=t=>this.#b("onWheel",t);stop=t=>{const e=t=>{if(!(t.name in this.#v))return;const e=this.#v[t.name];e.onStop&&e.onStop(),this.#w[t.name]=e,delete this.#v[t.name]};return t?t.forEach(t=>{e(t)}):(()=>{this.#m.removeEventListener("pointerdown",this.#E),this.#y.removeEventListener("pointermove",this.#S),this.#y.removeEventListener("pointerup",this.#x),this.#m.removeEventListener("wheel",this.#M),this.#b("onStop")})(),this};start=t=>{const e=t=>{if(!(t.name in this.#w))return;const e=this.#w[t.name];e.onStart&&e.onStart(),this.#v[t.name]=e,delete this.#w[t.name]};return t?t.forEach(t=>{e(t)}):(()=>{this.#m.addEventListener("pointerdown",this.#E),this.#y.addEventListener("pointermove",this.#S),this.#y.addEventListener("pointerup",this.#x),this.#m.addEventListener("wheel",this.#M,{passive:!1}),this.#b("onStart")})(),this};dispose=()=>{this.stop(),this.#g=null,this.#b("dispose"),this.#P={}}}export{t as BaseModule,i as Click,s as Drag,a as Lubricator,o as MultitouchPanZoom,l as Pointeract,n as PreventDefault,r as WheelPanZoom,c as dragPreset,h as panPreset,d as zoomPreset};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/baseModule.ts","../src/utils.ts","../src/modules/click.ts","../src/modules/drag.ts","../src/modules/multitouchPanZoom.ts","../src/modules/preventDefault.ts","../src/modules/wheelPanZoom.ts","../src/modules/lubricator.ts","../src/pointeract.ts"],"sourcesContent":["import type {\n\tBaseOptions,\n\tGeneralObject,\n\tPointer,\n\tPointers,\n\tStdEvents,\n\tConstrain,\n} from '@/declarations';\nimport type { Pointeract, PointeractInterface } from '@/pointeract';\n\nexport type HookKeys =\n\t| 'onPointerDown'\n\t| 'onPointerUp'\n\t| 'onPointerMove'\n\t| 'onWheel'\n\t| 'onStart'\n\t| 'onStop'\n\t| 'dispose';\n\nexport type BaseArgs = [\n\tPointeract<[]>['moduleUtils'],\n\tWindow,\n\tPointers,\n\tHTMLElement,\n\tGeneralObject,\n];\n\nexport default class BaseModule<\n\tO extends BaseOptions = BaseOptions,\n\tE extends StdEvents = StdEvents,\n\tA extends {} = {},\n> {\n\tdeclare private static readonly _BaseModuleBrand: unique symbol; // Nominal marker\n\tdeclare readonly _Events: E;\n\tdeclare readonly _Augmentation: A;\n\tprotected getNthPointer: Pointeract<[]>['moduleUtils']['getNthPointer'];\n\tprotected toTargetCoords: Pointeract<[]>['moduleUtils']['toTargetCoords'];\n\tprotected augment: (augmentation: A) => void;\n\tprotected dispatch: <K extends keyof Constrain<E>>(\n\t\t...arg: undefined extends E[K] ? [K] : [K, E[K]]\n\t) => void;\n\toptions: O;\n\tconstructor(\n\t\tutils: PointeractInterface['moduleUtils'],\n\t\tprotected window: Window,\n\t\tprotected pointers: Pointers,\n\t\tprotected element: HTMLElement,\n\t\toptions: GeneralObject,\n\t) {\n\t\tthis.getNthPointer = utils.getNthPointer;\n\t\tthis.toTargetCoords = utils.toTargetCoords;\n\t\tthis.augment = utils.augment;\n\t\tthis.dispatch = utils.dispatch as typeof this.dispatch;\n\t\tthis.options = options;\n\t}\n\n\tonPointerDown?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;\n\tonPointerUp?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;\n\tonPointerMove?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;\n\tonWheel?: (...args: [event: WheelEvent]) => void;\n\tonStart?: () => void;\n\tonStop?: () => void;\n\tdispose?: () => void;\n\tmodifiers?: {\n\t\t[K in keyof Constrain<E>]?: (event: E[K]) => boolean | E[K];\n\t};\n}\n","import { GeneralObject } from '@/declarations';\n\nexport function getLast<T>(arr: Array<T>, num: number = 0) {\n\treturn arr[arr.length - 1 - num];\n}\n\nexport function fillIn(patch: GeneralObject, target: GeneralObject) {\n\tfor (const [k, v] of Object.entries(patch)) if (!(k in target)) target[k] = v;\n}\n\nexport function toArray<T>(toTrans: T | Array<T>) {\n\treturn Array.isArray(toTrans) ? toTrans : [toTrans];\n}\n","import type { BaseOptions, Pointer, Pointers } from '@/declarations';\n\nimport BaseModule from '@/baseModule';\nimport { getLast } from '@/utils';\n\ninterface Options extends BaseOptions {\n\tclickPreserveTime?: number;\n\tmoveThreshold?: number;\n}\n\nexport default class Click extends BaseModule<Options> {\n\t#lastClickTime = -Infinity;\n\t#clickSteak = 0;\n\n\tonPointerDown = (_e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tconst pointer0 = this.getNthPointer(0);\n\t\t\t/*\n interrupted means that when a pointer is moving on the screen while another pointer is down, possibly for zooming, both pointers will be seen as \"interrupted\" so that they won't be used for triggering a real click.\n */\n\t\t\tpointer0.interrupted = true;\n\t\t\tpointer.interrupted = true;\n\t\t}\n\t};\n\n\tonPointerUp = (e: PointerEvent, pointer: Pointer) => {\n\t\tif (pointer.interrupted) return;\n\t\tconst threshold = this.options.moveThreshold ?? 5;\n\t\tif (\n\t\t\tMath.abs(pointer.records[0].x - e.clientX) >= threshold ||\n\t\t\tMath.abs(pointer.records[0].y - e.clientY) >= threshold\n\t\t)\n\t\t\treturn;\n\t\tconst newLast = getLast(pointer.records).timestamp;\n\t\tconst time = this.options.clickPreserveTime ?? 400;\n\t\tif (newLast - this.#lastClickTime <= time) this.#clickSteak++;\n\t\telse this.#clickSteak = 1;\n\t\tthis.#lastClickTime = newLast;\n\t\tconst coords = this.toTargetCoords({ x: e.clientX, y: e.clientY });\n\t\tthis.dispatch('trueClick', {\n\t\t\t...coords,\n\t\t\ttarget: pointer.target,\n\t\t\tstreak: this.#clickSteak,\n\t\t});\n\t};\n}\n","import type { Pointer, Pointers } from '@/declarations';\n\nimport BaseModule from '@/baseModule';\nimport { getLast } from '@/utils';\n\nexport default class Drag extends BaseModule {\n\tonPointerMove = (e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tconst last = getLast(pointer.records, 1);\n\t\tif (pointers.size === 1) {\n\t\t\tconst dx = e.clientX - last.x;\n\t\t\tconst dy = e.clientY - last.y;\n\t\t\tthis.dispatch('drag', { deltaX: dx, deltaY: dy, x: e.clientX, y: e.clientY });\n\t\t}\n\t};\n}\n","import type { Coordinates, Pointer, Pointers } from '@/declarations';\n\nimport BaseModule from '@/baseModule';\nimport { getLast } from '@/utils';\n\nexport default class MultitouchPanZoom extends BaseModule {\n\t#pinchZoomState = {\n\t\tlastDistance: 0,\n\t\tlastMidpoint: { x: 0, y: 0 },\n\t};\n\n\t#getPointerDistance() {\n\t\tconst pointer0Coords = getLast(this.getNthPointer(0).records);\n\t\tconst pointer1Coords = getLast(this.getNthPointer(1).records);\n\t\tconst dx = pointer0Coords.x - pointer1Coords.x;\n\t\tconst dy = pointer0Coords.y - pointer1Coords.y;\n\t\treturn Math.sqrt(dx * dx + dy * dy);\n\t}\n\n\t// output screen coords\n\t#getPointerMidpoint() {\n\t\tconst pointer0Coords = getLast(this.getNthPointer(0).records);\n\t\tconst pointer1Coords = getLast(this.getNthPointer(1).records);\n\t\treturn {\n\t\t\tx: (pointer0Coords.x + pointer1Coords.x) / 2,\n\t\t\ty: (pointer0Coords.y + pointer1Coords.y) / 2,\n\t\t};\n\t}\n\n\tonPointerDown = (_e: PointerEvent, _pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tthis.#pinchZoomState.lastDistance = this.#getPointerDistance();\n\t\t\tthis.#pinchZoomState.lastMidpoint = this.toTargetCoords(this.#getPointerMidpoint());\n\t\t}\n\t};\n\n\tonPointerMove = (_e: PointerEvent, _pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tconst newDistance = this.#getPointerDistance();\n\t\t\tconst newMidpointOnScreen = this.#getPointerMidpoint();\n\t\t\tconst zoomFactor = newDistance / this.#pinchZoomState.lastDistance;\n\t\t\tthis.#pinchZoomState.lastDistance = newDistance;\n\t\t\tconst newMidpoint = this.toTargetCoords(newMidpointOnScreen);\n\t\t\tconst dx = newMidpoint.x - this.#pinchZoomState.lastMidpoint.x;\n\t\t\tconst dy = newMidpoint.y - this.#pinchZoomState.lastMidpoint.y;\n\t\t\tthis.#pinchZoomState.lastMidpoint = newMidpoint;\n\t\t\tthis.#dispatchPanEvent({ deltaX: dx, deltaY: dy });\n\t\t\tthis.#dispatchZoomEvent(zoomFactor, newMidpoint);\n\t\t}\n\t};\n\n\t#dispatchZoomEvent(factor: number, origin: Coordinates) {\n\t\tthis.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: { deltaX: number; deltaY: number }) {\n\t\tthis.dispatch('pan', diff);\n\t}\n}\n","import BaseModule from '@/baseModule';\n\nexport default class PreventDefault extends BaseModule {\n\tonWheel = (e: WheelEvent) => e.preventDefault();\n\t#preventDefaultFunction = (e: Event) => e.preventDefault();\n\n\tonStart = () => {\n\t\tthis.element.style.touchAction = 'none';\n\t\tthis.element.addEventListener('gesturestart', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t\tthis.element.addEventListener('gesturechange', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t};\n\n\tonStop = () => {\n\t\tthis.element.style.touchAction = '';\n\t\tthis.element.removeEventListener('gesturestart', this.#preventDefaultFunction);\n\t\tthis.element.removeEventListener('gesturechange', this.#preventDefaultFunction);\n\t};\n\n\tdispose = this.onStop;\n}\n","import type { Coordinates, BaseOptions } from '@/declarations';\n\nimport BaseModule, { BaseArgs } from '@/baseModule';\nimport { fillIn } from '@/utils';\n\n/*\nto normal computer users:\n\n# normal schema\ndiff y > 0 => zooms in => zoom factor < 1\ndiff y < 0 => zooms out => zoom factor > 1\n\n# professional schema\ndiff y > 0 => pan up => pan y < 0\ndiff y < 0 => pan down => pan y > 0\ndiff x > 0 => pan left => pan x < 0\ndiff y < 0 => pan right => pan y > 0\n*/\n\ninterface Options extends BaseOptions {\n\tproControlSchema?: boolean;\n\tzoomFactor?: number;\n\tlockControlSchema?: boolean;\n}\n\nexport default class wheelPanZoom extends BaseModule<Options> {\n\tconstructor(...args: BaseArgs) {\n\t\tsuper(...args);\n\t\tfillIn(\n\t\t\t{ proControlSchema: false, zoomFactor: 0.1, lockControlSchema: false },\n\t\t\tthis.options,\n\t\t);\n\t}\n\n\tonWheel = (e: WheelEvent) => {\n\t\tconst options = this.options as Required<Options>;\n\t\tif (\n\t\t\t!options.proControlSchema &&\n\t\t\t!options.lockControlSchema &&\n\t\t\t(e.ctrlKey || e.shiftKey || Math.abs(e.deltaX) > Math.abs(e.deltaY))\n\t\t)\n\t\t\toptions.proControlSchema = true;\n\t\tif (options.proControlSchema) {\n\t\t\tif (e.ctrlKey) {\n\t\t\t\tconst scaleFactor = 1 - options.zoomFactor * e.deltaY;\n\t\t\t\tconst origin = this.toTargetCoords({ x: e.clientX, y: e.clientY });\n\t\t\t\tthis.#dispatchZoomEvent(scaleFactor, origin);\n\t\t\t} else if (e.shiftKey && Math.abs(e.deltaX) <= Math.abs(e.deltaY))\n\t\t\t\tthis.#dispatchPanEvent({ deltaX: -e.deltaY, deltaY: -e.deltaX });\n\t\t\telse this.#dispatchPanEvent({ deltaX: -e.deltaX, deltaY: -e.deltaY });\n\t\t} else {\n\t\t\tconst scaleFactor = 1 - (options.zoomFactor / 20) * e.deltaY;\n\t\t\tconst origin = this.toTargetCoords({ x: e.clientX, y: e.clientY });\n\t\t\tthis.#dispatchZoomEvent(scaleFactor, origin);\n\t\t}\n\t};\n\n\t#dispatchZoomEvent(factor: number, origin: Coordinates) {\n\t\tthis.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: { deltaX: number; deltaY: number }) {\n\t\tthis.dispatch('pan', diff);\n\t}\n}\n","import BaseModule, { BaseArgs } from '@/baseModule';\nimport { BaseOptions, Events, GeneralObject } from '@/declarations';\n\ninterface Options extends BaseOptions {\n\tlubricator?: Record<string, PerEventOption>;\n}\n\ntype PerEventOption = {\n\tdecayFactor: number;\n\tfields: Record<string, { countType: 'sum' | 'product'; diminishBoundary: number }>;\n};\n\ntype PerEventStates = {\n\tsample: GeneralObject;\n\tfields: Record<\n\t\tstring,\n\t\t{\n\t\t\tcatch: number;\n\t\t\trelease: number;\n\t\t}\n\t>;\n};\n\nexport default class Lubricator extends BaseModule<Options> {\n\t#states: Record<string, PerEventStates> = {};\n\t#animationId: number | null = null;\n\n\tconstructor(...args: BaseArgs) {\n\t\tsuper(...args);\n\t\tconst lubricatee = this.options.lubricator;\n\t\tif (!lubricatee) return;\n\t\tObject.entries(lubricatee).forEach(([key, value]) => {\n\t\t\t// per event scope\n\t\t\tconst states = {\n\t\t\t\tsample: {},\n\t\t\t\tfields: {},\n\t\t\t} as PerEventStates;\n\t\t\tObject.keys(value.fields).forEach((field) => {\n\t\t\t\tstates.fields[field] = {\n\t\t\t\t\tcatch: 1,\n\t\t\t\t\trelease: 1,\n\t\t\t\t};\n\t\t\t});\n\t\t\tthis.#states[key] = states;\n\t\t\tthis.modifiers[key] = this.#makeLubricate(states, value);\n\t\t});\n\t}\n\n\tonStart = () => {\n\t\tthis.#animationId = requestAnimationFrame(this.#perFrame);\n\t};\n\n\tonStop = () => {\n\t\tif (this.#animationId) cancelAnimationFrame(this.#animationId);\n\t\tthis.#animationId = null;\n\t\tObject.values(this.#states).forEach((value) => {\n\t\t\t// per event scope\n\t\t\tObject.values(value.fields).forEach((value) => {\n\t\t\t\t// per field scope\n\t\t\t\tvalue.release = 1;\n\t\t\t\tvalue.catch = 1;\n\t\t\t});\n\t\t});\n\t};\n\n\t#makeLubricate =\n\t\t(states: PerEventStates, options: PerEventOption) => (detail: GeneralObject) => {\n\t\t\tif (detail.lubricated) return true;\n\t\t\tstates.sample = detail;\n\t\t\tthis.#accumulate(states.fields, options.fields, detail);\n\t\t\treturn false;\n\t\t};\n\n\t#accumulate = (\n\t\tstateFields: PerEventStates['fields'],\n\t\toptionsFields: PerEventOption['fields'],\n\t\tdetail: GeneralObject,\n\t) => {\n\t\tObject.entries(stateFields).forEach(([key, value]) => {\n\t\t\tif (typeof detail[key] !== 'number') return;\n\t\t\tconst config = optionsFields[key].countType;\n\t\t\tif (config === 'sum') {\n\t\t\t\tvalue.catch += detail[key];\n\t\t\t} else if (config === 'product') value.catch *= detail[key];\n\t\t});\n\t};\n\n\t#perFrame = () => {\n\t\tconst states = this.#states;\n\t\tconst options = this.options.lubricator;\n\t\tif (!options) return;\n\t\tObject.entries(states).forEach(([event, perEventStates]) => {\n\t\t\t// per event scope\n\t\t\tconst detail = perEventStates.sample;\n\t\t\tdetail.lubricated = true;\n\t\t\tlet needEmit = false;\n\t\t\tfor (const [field, value] of Object.entries(perEventStates.fields)) {\n\t\t\t\t// per field scope\n\t\t\t\tif (value.catch === 1) continue;\n\t\t\t\tconst type = options[event].fields[field].countType;\n\n\t\t\t\tlet absDiff: number, diff: number;\n\t\t\t\tif (type === 'sum') {\n\t\t\t\t\tdiff = value.catch - value.release;\n\t\t\t\t\tabsDiff = Math.abs(diff);\n\t\t\t\t} else {\n\t\t\t\t\tdiff = value.catch / value.release;\n\t\t\t\t\tabsDiff = this.#reciprocalAbs(diff) - 1;\n\t\t\t\t}\n\n\t\t\t\tif (absDiff <= options[event].fields[field].diminishBoundary) {\n\t\t\t\t\tif (!needEmit) needEmit = true;\n\t\t\t\t\tdetail[field] = diff;\n\t\t\t\t\tvalue.release = 1;\n\t\t\t\t\tvalue.catch = 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// more to interpolate\n\t\t\t\tlet delta: number;\n\t\t\t\tif (type === 'sum') {\n\t\t\t\t\tdelta = diff * options[event].decayFactor;\n\t\t\t\t\tvalue.release += delta;\n\t\t\t\t} else {\n\t\t\t\t\tdelta = Math.pow(diff, options[event].decayFactor);\n\t\t\t\t\tvalue.release *= delta;\n\t\t\t\t}\n\t\t\t\tdetail[field] = delta;\n\t\t\t\tneedEmit = true;\n\t\t\t}\n\t\t\tif (needEmit) this.dispatch(event as keyof Events, detail as never);\n\t\t});\n\t\tthis.#animationId = requestAnimationFrame(this.#perFrame);\n\t};\n\n\t// in: positive number; out: positive number > 1\n\t#reciprocalAbs = (num: number) => (num > 1 ? num : 1 / num);\n\n\t// oxlint-disable-next-line typescript/no-explicit-any\n\tmodifiers: Record<string, any> = {};\n}\n\nexport const panPreset = {\n\tdecayFactor: 0.25,\n\tfields: {\n\t\tdeltaX: {\n\t\t\tcountType: 'sum',\n\t\t\tdiminishBoundary: 0.5,\n\t\t},\n\t\tdeltaY: {\n\t\t\tcountType: 'sum',\n\t\t\tdiminishBoundary: 0.5,\n\t\t},\n\t},\n} satisfies PerEventOption;\n\nexport const dragPreset = panPreset;\n\nexport const zoomPreset = {\n\tdecayFactor: 0.25,\n\tfields: {\n\t\tfactor: {\n\t\t\tcountType: 'product',\n\t\t\tdiminishBoundary: 0.01,\n\t\t},\n\t},\n} satisfies PerEventOption;\n","import type BaseModule from '@/baseModule';\nimport type {\n\tAugmentation,\n\tCoordinates,\n\tEvents,\n\tGeneralObject,\n\tModuleCtor,\n\tModuleInput,\n\tModuleInputCtor,\n\tOptions,\n\tPointers,\n\tReloadable,\n} from '@/declarations';\n\nimport { HookKeys } from '@/baseModule';\nimport { toArray } from '@/utils';\n\nexport class Pointeract<T extends ModuleInputCtor = []> {\n\t#element: HTMLElement;\n\t#pointers: Pointers = new Map();\n\t#modules: Record<string, BaseModule> = {};\n\t#pausedModules: Record<string, BaseModule> = {};\n\t#_window: Window | null;\n\t#subscribers: { [K in keyof Events<T>]?: Set<(event: Events<T>[K]) => void> } = {};\n\toptions: Options<T>;\n\tdeclare private _augmentSlot: unknown;\n\n\tget #window() {\n\t\tif (!this.#_window) throw new Error('[Pointeract] Window is not defined.');\n\t\treturn this.#_window;\n\t}\n\n\tconstructor(options: Options<T>, _modules?: T) {\n\t\tconst modules = toArray(_modules ? _modules : ([] as Array<ModuleCtor>));\n\t\tthis.#_window = options.element.ownerDocument.defaultView;\n\t\tthis.#element = options.element;\n\t\tif (!options.coordinateOutput) options.coordinateOutput = 'relative';\n\t\tthis.options = options;\n\t\tmodules.forEach((module) => {\n\t\t\tconst instance = new module(\n\t\t\t\tthis.moduleUtils as PointeractInterface['moduleUtils'],\n\t\t\t\tthis.#window,\n\t\t\t\tthis.#pointers,\n\t\t\t\tthis.#element,\n\t\t\t\tthis.options,\n\t\t\t);\n\t\t\tObject.assign(instance, { options });\n\t\t\tthis.#modules[module.name] = instance;\n\t\t});\n\t}\n\n\ton = <K extends keyof Events<T>>(type: K, listener: (event: Events<T>[K]) => void) => {\n\t\tif (!this.#subscribers[type]) this.#subscribers[type] = new Set();\n\t\tthis.#subscribers[type]?.add(listener);\n\t\treturn this;\n\t};\n\toff<K extends keyof Events<T>>(type: K, listener: (event: Events<T>[K]) => void) {\n\t\tthis.#subscribers[type]?.delete(listener);\n\t\treturn this;\n\t}\n\n\tprivate moduleUtils = {\n\t\tgetNthPointer: (n: number) => {\n\t\t\tconst error = new Error('[Pointeract] Invalid pointer index.');\n\t\t\tif (n < 0 || n >= this.#pointers.size) throw error;\n\t\t\tlet i = 0;\n\t\t\tfor (const value of this.#pointers.values()) {\n\t\t\t\tif (i === n) return value;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tthrow error;\n\t\t},\n\n\t\t// Screen to Container\n\t\ttoTargetCoords: (raw: Coordinates) => {\n\t\t\tif (this.options.coordinateOutput === 'absolute') return raw;\n\t\t\tconst rect = this.#element.getBoundingClientRect();\n\t\t\traw.x -= rect.left;\n\t\t\traw.y -= rect.top;\n\t\t\tif (this.options.coordinateOutput === 'relative') return raw;\n\t\t\traw.x /= rect.width;\n\t\t\traw.y /= rect.height;\n\t\t\treturn raw;\n\t\t},\n\n\t\tdispatch: <N extends keyof Events<T>>(\n\t\t\t...args: undefined extends Events<T>[N] ? [N] : [N, Events<T>[N]]\n\t\t) => {\n\t\t\tconst name = args[0];\n\t\t\tconst e = args[1];\n\t\t\tlet lastResult: boolean | Events<T>[N] = true;\n\t\t\tfor (const value of Object.values(this.#modules)) {\n\t\t\t\tif (!value.modifiers || !(name in value.modifiers)) continue;\n\t\t\t\tlastResult =\n\t\t\t\t\te === undefined\n\t\t\t\t\t\t? (value.modifiers[name] as () => boolean)()\n\t\t\t\t\t\t: (\n\t\t\t\t\t\t\t\tvalue.modifiers[name] as (\n\t\t\t\t\t\t\t\t\tdetail?: Events<T>[N],\n\t\t\t\t\t\t\t\t) => boolean | Events<T>[N]\n\t\t\t\t\t\t\t)(e);\n\t\t\t\tif (lastResult === false) return;\n\t\t\t}\n\t\t\tlet event: Events<T>[N];\n\t\t\tif (lastResult === true) event = e as Events<T>[N];\n\t\t\telse event = lastResult;\n\t\t\tthis.#subscribers[name]?.forEach((listener) => listener(event));\n\t\t},\n\n\t\taugment: (aug: GeneralObject) => {\n\t\t\tObject.entries(aug).forEach(([key, value]) => (this[key as '_augmentSlot'] = value));\n\t\t},\n\t};\n\n\tdispatch = this.moduleUtils.dispatch;\n\n\t#runHooks<K extends HookKeys>(field: K, ...args: Parameters<Required<BaseModule>[K]>) {\n\t\tObject.values(this.#modules).forEach((module) => {\n\t\t\tconst hook = module[field];\n\t\t\t// oxlint-disable-next-line typescript/no-explicit-any\n\t\t\tif (hook) hook(...(args as any));\n\t\t});\n\t}\n\n\t#onPointerDown = (e: PointerEvent) => {\n\t\tif (this.#pointers.size >= 2) return;\n\t\tif (e.isPrimary) this.#pointers.clear();\n\t\tconst pointer = {\n\t\t\trecords: [{ x: e.clientX, y: e.clientY, timestamp: Date.now() }],\n\t\t\ttarget: e.target,\n\t\t};\n\t\tthis.#pointers.set(e.pointerId, pointer);\n\t\tthis.#runHooks('onPointerDown', e, pointer, this.#pointers);\n\t};\n\n\t#onPointerMove = (e: PointerEvent) => {\n\t\tconst pointer = this.#pointers.get(e.pointerId);\n\t\tif (!pointer) return;\n\t\tpointer.records.push({ x: e.clientX, y: e.clientY, timestamp: Date.now() });\n\t\tthis.#runHooks('onPointerMove', e, pointer, this.#pointers);\n\t};\n\n\t#onPointerUp = (e: PointerEvent) => {\n\t\tconst pointer = this.#pointers.get(e.pointerId);\n\t\tif (!pointer) return;\n\t\tthis.#pointers.delete(e.pointerId);\n\t\tthis.#runHooks('onPointerUp', e, pointer, this.#pointers);\n\t};\n\n\t#onWheel = (e: WheelEvent) => this.#runHooks('onWheel', e);\n\n\tstop = (_toStop?: Reloadable<T>) => {\n\t\tconst stopPointeract = () => {\n\t\t\tthis.#element.removeEventListener('pointerdown', this.#onPointerDown);\n\t\t\tthis.#window.removeEventListener('pointermove', this.#onPointerMove);\n\t\t\tthis.#window.removeEventListener('pointerup', this.#onPointerUp);\n\t\t\tthis.#element.removeEventListener('wheel', this.#onWheel);\n\t\t\tthis.#runHooks('onStop');\n\t\t};\n\t\tconst stopModule = (moduleCtor: ModuleCtor) => {\n\t\t\tif (!(moduleCtor.name in this.#modules)) return;\n\t\t\tconst module = this.#modules[moduleCtor.name];\n\t\t\tif (module.onStop) module.onStop();\n\t\t\tthis.#pausedModules[moduleCtor.name] = module;\n\t\t\tdelete this.#modules[moduleCtor.name];\n\t\t};\n\t\tif (!_toStop) stopPointeract();\n\t\telse\n\t\t\ttoArray(_toStop).forEach((module) => {\n\t\t\t\tstopModule(module);\n\t\t\t});\n\t\treturn this;\n\t};\n\n\tstart = (_toStart?: Reloadable<T>) => {\n\t\tconst startPointeract = () => {\n\t\t\tthis.#element.addEventListener('pointerdown', this.#onPointerDown);\n\t\t\tthis.#window.addEventListener('pointermove', this.#onPointerMove);\n\t\t\tthis.#window.addEventListener('pointerup', this.#onPointerUp);\n\t\t\tthis.#element.addEventListener('wheel', this.#onWheel, { passive: false });\n\t\t\tthis.#runHooks('onStart');\n\t\t};\n\t\tconst startModule = (moduleCtor: ModuleCtor) => {\n\t\t\tif (!(moduleCtor.name in this.#pausedModules)) return;\n\t\t\tconst module = this.#pausedModules[moduleCtor.name];\n\t\t\tif (module.onStart) module.onStart();\n\t\t\tthis.#modules[moduleCtor.name] = module;\n\t\t\tdelete this.#pausedModules[moduleCtor.name];\n\t\t};\n\t\tif (!_toStart) startPointeract();\n\t\telse\n\t\t\ttoArray(_toStart).forEach((module) => {\n\t\t\t\tstartModule(module);\n\t\t\t});\n\t\treturn this;\n\t};\n\n\tdispose = () => {\n\t\tthis.stop();\n\t\tthis.#_window = null;\n\t\tthis.#runHooks('dispose');\n\t\tthis.#subscribers = {};\n\t};\n}\n\ntype PointeractType = new <M extends ModuleInputCtor = []>(\n\t...args: ConstructorParameters<typeof Pointeract<M>>\n) => Pointeract<M> & Augmentation<M>;\n\nexport type PointeractInterface<M extends ModuleInput = []> = Pointeract<never> & Augmentation<M>;\n\nexport default Pointeract as PointeractType;\n"],"names":["BaseModule","constructor","utils","window","pointers","element","options","this","getNthPointer","toTargetCoords","augment","dispatch","onPointerDown","onPointerUp","onPointerMove","onWheel","onStart","onStop","dispose","modifiers","getLast","arr","num","length","toArray","toTrans","Array","isArray","Click","lastClickTime","Infinity","clickSteak","_e","pointer","size","interrupted","e","threshold","moveThreshold","Math","abs","records","x","clientX","y","clientY","newLast","timestamp","time","clickPreserveTime","coords","target","streak","Drag","last","dx","dy","deltaX","deltaY","MultitouchPanZoom","pinchZoomState","lastDistance","lastMidpoint","getPointerDistance","pointer0Coords","pointer1Coords","sqrt","getPointerMidpoint","_pointer","newDistance","newMidpointOnScreen","zoomFactor","newMidpoint","dispatchPanEvent","dispatchZoomEvent","factor","origin","diff","PreventDefault","preventDefault","preventDefaultFunction","style","touchAction","addEventListener","passive","removeEventListener","wheelPanZoom","args","super","patch","k","v","Object","entries","fillIn","proControlSchema","lockControlSchema","ctrlKey","shiftKey","scaleFactor","Lubricator","states","animationId","lubricatee","lubricator","forEach","key","value","sample","fields","keys","field","catch","release","makeLubricate","requestAnimationFrame","perFrame","cancelAnimationFrame","values","detail","lubricated","accumulate","stateFields","optionsFields","config","countType","event","perEventStates","needEmit","type","absDiff","delta","reciprocalAbs","diminishBoundary","decayFactor","pow","panPreset","dragPreset","zoomPreset","Pointeract","Map","modules","pausedModules","_window","subscribers","Error","_modules","ownerDocument","defaultView","coordinateOutput","module","instance","moduleUtils","assign","name","on","listener","Set","add","off","delete","n","error","i","raw","rect","getBoundingClientRect","left","top","width","height","lastResult","aug","runHooks","hook","isPrimary","clear","Date","now","set","pointerId","get","push","stop","_toStop","stopModule","moduleCt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E,MAAKQ,EAAU,CAAEqE,SAAS,IAClE7E,MAAKsK,EAAU,YASDkB,GAKRxL,MAGRW,QAAU,KACTX,KAAKgL,OACLhL,MAAKwI,EAAW,KAChBxI,MAAKsK,EAAU,WACftK,MAAKyI,EAAe,CAAA"}
1
+ {"version":3,"file":"index.js","sources":["../src/BaseModule.ts","../src/utils.ts","../src/modules/Click.ts","../src/modules/Drag.ts","../src/modules/MultitouchPanZoom.ts","../src/modules/PreventDefault.ts","../src/modules/WheelPanZoom.ts","../src/modules/Lubricator.ts","../src/Pointeract.ts"],"sourcesContent":["import type { Pointeract, PointeractInterface } from '@/Pointeract';\nimport type {\n\tBaseOptions,\n\tGeneralObject,\n\tPointer,\n\tPointers,\n\tStdEvents,\n\tModuleInput as MI,\n\tOrchestratable,\n\tGeneral,\n} from '@/types';\n\nexport type HookKeys =\n\t| 'onPointerDown'\n\t| 'onPointerUp'\n\t| 'onPointerMove'\n\t| 'onWheel'\n\t| 'onStart'\n\t| 'onStop'\n\t| 'dispose';\n\nexport type BaseArgs = ConstructorParameters<typeof BaseModule>;\nexport type ModuleCtor = typeof BaseModule<General, General, General>;\n\nexport type ModuleInput = MI<ModuleCtor>;\nexport type ModuleInputCtor = ReadonlyArray<ModuleCtor>;\nexport type Options<T extends ModuleInput = []> = Orchestratable<T, 'options'> & BaseOptions;\nexport type Events<T extends ModuleInput = []> = Orchestratable<T, '_Events'> & StdEvents;\nexport type Augmentation<T extends ModuleInput = []> = Orchestratable<T, '_Augmentation'>;\n\nexport default class BaseModule<\n\tO extends BaseOptions = BaseOptions,\n\tE extends StdEvents = StdEvents,\n\tA extends {} = {},\n> {\n\tdeclare private static readonly _BaseModuleBrand: unique symbol; // Nominal marker\n\tdeclare readonly _Events: E;\n\tdeclare readonly _Augmentation: A;\n\tprotected getNthPointer: Pointeract<[]>['moduleUtils']['getNthPointer'];\n\tprotected toTargetCoords: Pointeract<[]>['moduleUtils']['toTargetCoords'];\n\tprotected augment: (augmentation: A) => void;\n\tprotected dispatch: <K extends keyof E>(\n\t\t...arg: undefined extends E[K] ? [K] : [K, E[K]]\n\t) => void;\n\toptions: O;\n\tconstructor(\n\t\tutils: PointeractInterface['moduleUtils'],\n\t\tprotected window: Window,\n\t\tprotected pointers: Pointers,\n\t\tprotected element: HTMLElement,\n\t\toptions: GeneralObject,\n\t) {\n\t\tthis.getNthPointer = utils.getNthPointer;\n\t\tthis.toTargetCoords = utils.toTargetCoords;\n\t\tthis.augment = utils.augment;\n\t\tthis.dispatch = utils.dispatch as typeof this.dispatch;\n\t\tthis.options = options as O;\n\t}\n\n\tonPointerDown?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;\n\tonPointerUp?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;\n\tonPointerMove?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;\n\tonWheel?: (...args: [event: WheelEvent]) => void;\n\tonStart?: () => void;\n\tonStop?: () => void;\n\tdispose?: () => void;\n\tmodifiers?: {\n\t\t[K in keyof E]?: (event: E[K]) => boolean | E[K];\n\t};\n}\n","import { GeneralDictionary } from '@/types';\n\nexport function getLast<T>(arr: Array<T>, num: number = 0) {\n\treturn arr[arr.length - 1 - num];\n}\n\nexport function fillIn(patch: GeneralDictionary, target: GeneralDictionary) {\n\tfor (const [k, v] of Object.entries(patch))\n\t\tif (!(k in target)) (target as Record<string, unknown>)[k] = v;\n}\n","import type { BaseOptions, Pointer, Pointers } from '@/types';\nimport BaseModule from '@/BaseModule';\nimport { getLast } from '@/utils';\n\ninterface Options extends BaseOptions {\n\tclickPreserveTime?: number;\n\tmoveThreshold?: number;\n}\n\nexport default class Click extends BaseModule<Options> {\n\t#lastClickTime = -Infinity;\n\t#clickSteak = 0;\n\n\tonPointerDown = (_e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tconst pointer0 = this.getNthPointer(0);\n\t\t\t/*\n interrupted means that when a pointer is moving on the screen while another pointer is down, possibly for zooming, both pointers will be seen as \"interrupted\" so that they won't be used for triggering a real click.\n */\n\t\t\tpointer0.interrupted = true;\n\t\t\tpointer.interrupted = true;\n\t\t}\n\t};\n\n\tonPointerUp = (e: PointerEvent, pointer: Pointer) => {\n\t\tif (pointer.interrupted) return;\n\t\tconst threshold = this.options.moveThreshold ?? 5;\n\t\tif (\n\t\t\tMath.abs(pointer.records[0].x - e.clientX) >= threshold ||\n\t\t\tMath.abs(pointer.records[0].y - e.clientY) >= threshold\n\t\t)\n\t\t\treturn;\n\t\tconst newLast = getLast(pointer.records).timestamp;\n\t\tconst time = this.options.clickPreserveTime ?? 400;\n\t\tif (newLast - this.#lastClickTime <= time) this.#clickSteak++;\n\t\telse this.#clickSteak = 1;\n\t\tthis.#lastClickTime = newLast;\n\t\tconst coords = this.toTargetCoords({ x: e.clientX, y: e.clientY });\n\t\tthis.dispatch('trueClick', {\n\t\t\t...coords,\n\t\t\ttarget: pointer.target,\n\t\t\tstreak: this.#clickSteak,\n\t\t});\n\t};\n}\n","import type { Pointer, Pointers } from '@/types';\nimport BaseModule from '@/BaseModule';\nimport { getLast } from '@/utils';\n\nexport default class Drag extends BaseModule {\n\tonPointerMove = (e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tconst last = getLast(pointer.records, 1);\n\t\tif (pointers.size === 1) {\n\t\t\tconst dx = e.clientX - last.x;\n\t\t\tconst dy = e.clientY - last.y;\n\t\t\tthis.dispatch('drag', { deltaX: dx, deltaY: dy, x: e.clientX, y: e.clientY });\n\t\t}\n\t};\n}\n","import type { Coordinates, Pointer, Pointers } from '@/types';\nimport BaseModule from '@/BaseModule';\nimport { getLast } from '@/utils';\n\nexport default class MultitouchPanZoom extends BaseModule {\n\t#pinchZoomState = {\n\t\tlastDistance: 0,\n\t\tlastMidpoint: { x: 0, y: 0 },\n\t};\n\n\t#getPointerDistance() {\n\t\tconst pointer0Coords = getLast(this.getNthPointer(0).records);\n\t\tconst pointer1Coords = getLast(this.getNthPointer(1).records);\n\t\tconst dx = pointer0Coords.x - pointer1Coords.x;\n\t\tconst dy = pointer0Coords.y - pointer1Coords.y;\n\t\treturn Math.sqrt(dx * dx + dy * dy);\n\t}\n\n\t// output screen coords\n\t#getPointerMidpoint() {\n\t\tconst pointer0Coords = getLast(this.getNthPointer(0).records);\n\t\tconst pointer1Coords = getLast(this.getNthPointer(1).records);\n\t\treturn {\n\t\t\tx: (pointer0Coords.x + pointer1Coords.x) / 2,\n\t\t\ty: (pointer0Coords.y + pointer1Coords.y) / 2,\n\t\t};\n\t}\n\n\tonPointerDown = (_e: PointerEvent, _pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tthis.#pinchZoomState.lastDistance = this.#getPointerDistance();\n\t\t\tthis.#pinchZoomState.lastMidpoint = this.toTargetCoords(this.#getPointerMidpoint());\n\t\t}\n\t};\n\n\tonPointerMove = (_e: PointerEvent, _pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tconst newDistance = this.#getPointerDistance();\n\t\t\tconst newMidpointOnScreen = this.#getPointerMidpoint();\n\t\t\tconst zoomFactor = newDistance / this.#pinchZoomState.lastDistance;\n\t\t\tthis.#pinchZoomState.lastDistance = newDistance;\n\t\t\tconst newMidpoint = this.toTargetCoords(newMidpointOnScreen);\n\t\t\tconst dx = newMidpoint.x - this.#pinchZoomState.lastMidpoint.x;\n\t\t\tconst dy = newMidpoint.y - this.#pinchZoomState.lastMidpoint.y;\n\t\t\tthis.#pinchZoomState.lastMidpoint = newMidpoint;\n\t\t\tthis.#dispatchPanEvent({ deltaX: dx, deltaY: dy });\n\t\t\tthis.#dispatchZoomEvent(zoomFactor, newMidpoint);\n\t\t}\n\t};\n\n\t#dispatchZoomEvent(factor: number, origin: Coordinates) {\n\t\tthis.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: { deltaX: number; deltaY: number }) {\n\t\tthis.dispatch('pan', diff);\n\t}\n}\n","import BaseModule from '@/BaseModule';\n\nexport default class PreventDefault extends BaseModule {\n\tonWheel = (e: WheelEvent) => e.preventDefault();\n\t#preventDefaultFunction = (e: Event) => e.preventDefault();\n\n\tonStart = () => {\n\t\tthis.element.style.touchAction = 'none';\n\t\tthis.element.addEventListener('gesturestart', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t\tthis.element.addEventListener('gesturechange', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t};\n\n\tonStop = () => {\n\t\tthis.element.style.touchAction = '';\n\t\tthis.element.removeEventListener('gesturestart', this.#preventDefaultFunction);\n\t\tthis.element.removeEventListener('gesturechange', this.#preventDefaultFunction);\n\t};\n\n\tdispose = this.onStop;\n}\n","import type { Coordinates, BaseOptions } from '@/types';\nimport BaseModule, { BaseArgs } from '@/BaseModule';\nimport { fillIn } from '@/utils';\n\n/*\n# normal schema\ndiff y > 0 => zooms in => zoom factor < 1\ndiff y < 0 => zooms out => zoom factor > 1\n\n# professional schema\ndiff y > 0 => pan up => pan y < 0\ndiff y < 0 => pan down => pan y > 0\ndiff x > 0 => pan left => pan x < 0\ndiff y < 0 => pan right => pan y > 0\n*/\n\ninterface Options extends BaseOptions {\n\tproControlSchema?: boolean;\n\tzoomFactor?: number;\n\tlockControlSchema?: boolean;\n}\n\nexport default class wheelPanZoom extends BaseModule<Options> {\n\tconstructor(...args: BaseArgs) {\n\t\tsuper(...args);\n\t\tfillIn(\n\t\t\t{ proControlSchema: false, zoomFactor: 0.1, lockControlSchema: false },\n\t\t\tthis.options,\n\t\t);\n\t}\n\n\tonWheel = (e: WheelEvent) => {\n\t\tconst options = this.options as Required<Options>;\n\t\tif (\n\t\t\t!options.proControlSchema &&\n\t\t\t!options.lockControlSchema &&\n\t\t\t(e.ctrlKey || e.shiftKey || Math.abs(e.deltaX) > Math.abs(e.deltaY))\n\t\t)\n\t\t\toptions.proControlSchema = true;\n\t\tif (options.proControlSchema) {\n\t\t\tif (e.ctrlKey) {\n\t\t\t\tconst scaleFactor = 1 - options.zoomFactor * e.deltaY;\n\t\t\t\tconst origin = this.toTargetCoords({ x: e.clientX, y: e.clientY });\n\t\t\t\tthis.#dispatchZoomEvent(scaleFactor, origin);\n\t\t\t} else if (e.shiftKey && Math.abs(e.deltaX) <= Math.abs(e.deltaY))\n\t\t\t\tthis.#dispatchPanEvent({ deltaX: -e.deltaY, deltaY: -e.deltaX });\n\t\t\telse this.#dispatchPanEvent({ deltaX: -e.deltaX, deltaY: -e.deltaY });\n\t\t} else {\n\t\t\tconst scaleFactor = 1 - (options.zoomFactor / 20) * e.deltaY;\n\t\t\tconst origin = this.toTargetCoords({ x: e.clientX, y: e.clientY });\n\t\t\tthis.#dispatchZoomEvent(scaleFactor, origin);\n\t\t}\n\t};\n\n\t#dispatchZoomEvent(factor: number, origin: Coordinates) {\n\t\tthis.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: { deltaX: number; deltaY: number }) {\n\t\tthis.dispatch('pan', diff);\n\t}\n}\n","import BaseModule, { BaseArgs, Events } from '@/BaseModule';\nimport { BaseOptions, GeneralDictionary } from '@/types';\n\ninterface Options extends BaseOptions {\n\tlubricator?: Record<string, PerEventOption>;\n}\n\ntype PerEventOption = {\n\tdecayFactor: number;\n\tfields: Record<string, { countType: 'sum' | 'product'; diminishBoundary: number }>;\n};\n\ntype PerEventStates = {\n\tsample: GeneralDictionary;\n\tfields: Record<\n\t\tstring,\n\t\t{\n\t\t\tcatch: number;\n\t\t\trelease: number;\n\t\t}\n\t>;\n};\n\nexport default class Lubricator extends BaseModule<Options> {\n\t#states: Record<string, PerEventStates> = {};\n\t#animationId: number | null = null;\n\n\tconstructor(...args: BaseArgs) {\n\t\tsuper(...args);\n\t\tconst lubricatee = this.options.lubricator;\n\t\tif (!lubricatee) return;\n\t\tObject.entries(lubricatee).forEach(([key, value]) => {\n\t\t\t// per event scope\n\t\t\tconst states = {\n\t\t\t\tsample: {},\n\t\t\t\tfields: {},\n\t\t\t} as PerEventStates;\n\t\t\tObject.keys(value.fields).forEach((field) => {\n\t\t\t\tstates.fields[field] = {\n\t\t\t\t\tcatch: 1,\n\t\t\t\t\trelease: 1,\n\t\t\t\t};\n\t\t\t});\n\t\t\tthis.#states[key] = states;\n\t\t\tthis.modifiers[key] = this.#makeLubricate(states, value);\n\t\t});\n\t}\n\n\tonStart = () => {\n\t\tthis.#animationId = requestAnimationFrame(this.#perFrame);\n\t};\n\n\tonStop = () => {\n\t\tif (this.#animationId) cancelAnimationFrame(this.#animationId);\n\t\tthis.#animationId = null;\n\t\tObject.values(this.#states).forEach((value) => {\n\t\t\t// per event scope\n\t\t\tObject.values(value.fields).forEach((value) => {\n\t\t\t\t// per field scope\n\t\t\t\tvalue.release = 1;\n\t\t\t\tvalue.catch = 1;\n\t\t\t});\n\t\t});\n\t};\n\n\t#makeLubricate =\n\t\t(states: PerEventStates, options: PerEventOption) => (detail: GeneralDictionary) => {\n\t\t\tif (detail.lubricated) return true;\n\t\t\tstates.sample = detail;\n\t\t\tthis.#accumulate(states.fields, options.fields, detail);\n\t\t\treturn false;\n\t\t};\n\n\t#accumulate = (\n\t\tstateFields: PerEventStates['fields'],\n\t\toptionsFields: PerEventOption['fields'],\n\t\tdetail: GeneralDictionary,\n\t) => {\n\t\tObject.entries(stateFields).forEach(([key, value]) => {\n\t\t\tif (typeof detail[key] !== 'number') return;\n\t\t\tconst config = optionsFields[key].countType;\n\t\t\tif (config === 'sum') {\n\t\t\t\tvalue.catch += detail[key];\n\t\t\t} else if (config === 'product') value.catch *= detail[key];\n\t\t});\n\t};\n\n\t#perFrame = () => {\n\t\tconst states = this.#states;\n\t\tconst options = this.options.lubricator;\n\t\tif (!options) return;\n\t\tObject.entries(states).forEach(([event, perEventStates]) => {\n\t\t\t// per event scope\n\t\t\tconst detail = perEventStates.sample;\n\t\t\tdetail.lubricated = true;\n\t\t\tlet needEmit = false;\n\t\t\tfor (const [field, value] of Object.entries(perEventStates.fields)) {\n\t\t\t\t// per field scope\n\t\t\t\tif (value.catch === 1) continue;\n\t\t\t\tconst type = options[event].fields[field].countType;\n\n\t\t\t\tlet absDiff: number, diff: number;\n\t\t\t\tif (type === 'sum') {\n\t\t\t\t\tdiff = value.catch - value.release;\n\t\t\t\t\tabsDiff = Math.abs(diff);\n\t\t\t\t} else {\n\t\t\t\t\tdiff = value.catch / value.release;\n\t\t\t\t\tabsDiff = this.#reciprocalAbs(diff) - 1;\n\t\t\t\t}\n\n\t\t\t\tif (absDiff <= options[event].fields[field].diminishBoundary) {\n\t\t\t\t\tif (!needEmit) needEmit = true;\n\t\t\t\t\tdetail[field] = diff;\n\t\t\t\t\tvalue.release = 1;\n\t\t\t\t\tvalue.catch = 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// more to interpolate\n\t\t\t\tlet delta: number;\n\t\t\t\tif (type === 'sum') {\n\t\t\t\t\tdelta = diff * options[event].decayFactor;\n\t\t\t\t\tvalue.release += delta;\n\t\t\t\t} else {\n\t\t\t\t\tdelta = Math.pow(diff, options[event].decayFactor);\n\t\t\t\t\tvalue.release *= delta;\n\t\t\t\t}\n\t\t\t\tdetail[field] = delta;\n\t\t\t\tneedEmit = true;\n\t\t\t}\n\t\t\tif (needEmit) this.dispatch(event as keyof Events, detail as never);\n\t\t});\n\t\tthis.#animationId = requestAnimationFrame(this.#perFrame);\n\t};\n\n\t// in: positive number; out: positive number > 1\n\t#reciprocalAbs = (num: number) => (num > 1 ? num : 1 / num);\n\n\t// oxlint-disable-next-line typescript/no-explicit-any\n\tmodifiers: Record<string, any> = {};\n}\n\nexport const panPreset = {\n\tdecayFactor: 0.25,\n\tfields: {\n\t\tdeltaX: {\n\t\t\tcountType: 'sum',\n\t\t\tdiminishBoundary: 0.5,\n\t\t},\n\t\tdeltaY: {\n\t\t\tcountType: 'sum',\n\t\t\tdiminishBoundary: 0.5,\n\t\t},\n\t},\n} satisfies PerEventOption;\n\nexport const dragPreset = panPreset;\n\nexport const zoomPreset = {\n\tdecayFactor: 0.25,\n\tfields: {\n\t\tfactor: {\n\t\t\tcountType: 'product',\n\t\t\tdiminishBoundary: 0.01,\n\t\t},\n\t},\n} satisfies PerEventOption;\n","import type BaseModule from '@/BaseModule';\nimport type {\n\tAugmentation,\n\tEvents,\n\tOptions,\n\tModuleCtor,\n\tModuleInputCtor,\n\tModuleInput,\n} from '@/BaseModule';\nimport type { Coordinates, GeneralObject, Pointers } from '@/types';\nimport { HookKeys } from '@/BaseModule';\n\ntype Reloadable<T extends ModuleInputCtor> = Array<T[number]>;\n\nexport class Pointeract<T extends ModuleInputCtor = []> {\n\t#element: HTMLElement;\n\t#pointers: Pointers = new Map();\n\t#modules: Record<string, BaseModule> = {};\n\t#pausedModules: Record<string, BaseModule> = {};\n\t#_window: Window | null;\n\t#subscribers: { [K in keyof Events<T>]?: Set<(event: Events<T>[K]) => void> } = {};\n\toptions: Options<T>;\n\tdeclare private _augmentSlot: unknown;\n\n\tget #window() {\n\t\tif (!this.#_window) throw new Error('[Pointeract] Window is not defined.');\n\t\treturn this.#_window;\n\t}\n\n\tconstructor(options: Options<T>, _modules?: T) {\n\t\tconst modules = _modules ? _modules : [];\n\t\tthis.#_window = options.element.ownerDocument.defaultView;\n\t\tthis.#element = options.element;\n\t\tif (!options.coordinateOutput) options.coordinateOutput = 'relative';\n\t\tthis.options = options;\n\t\tmodules.forEach((module) => {\n\t\t\tconst instance = new module(\n\t\t\t\tthis.moduleUtils as PointeractInterface['moduleUtils'],\n\t\t\t\tthis.#window,\n\t\t\t\tthis.#pointers,\n\t\t\t\tthis.#element,\n\t\t\t\tthis.options,\n\t\t\t);\n\t\t\tObject.assign(instance, { options });\n\t\t\tthis.#modules[module.name] = instance;\n\t\t});\n\t}\n\n\ton = <K extends keyof Events<T>>(type: K, listener: (event: Events<T>[K]) => void) => {\n\t\tif (!this.#subscribers[type]) this.#subscribers[type] = new Set();\n\t\tthis.#subscribers[type]?.add(listener);\n\t\treturn this;\n\t};\n\toff<K extends keyof Events<T>>(type: K, listener: (event: Events<T>[K]) => void) {\n\t\tthis.#subscribers[type]?.delete(listener);\n\t\treturn this;\n\t}\n\n\tprivate moduleUtils = {\n\t\tgetNthPointer: (n: number) => {\n\t\t\tconst error = new Error('[Pointeract] Invalid pointer index.');\n\t\t\tif (n < 0 || n >= this.#pointers.size) throw error;\n\t\t\tlet i = 0;\n\t\t\tfor (const value of this.#pointers.values()) {\n\t\t\t\tif (i === n) return value;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tthrow error;\n\t\t},\n\n\t\t// Screen to Container\n\t\ttoTargetCoords: (raw: Coordinates) => {\n\t\t\tif (this.options.coordinateOutput === 'absolute') return raw;\n\t\t\tconst rect = this.#element.getBoundingClientRect();\n\t\t\traw.x -= rect.left;\n\t\t\traw.y -= rect.top;\n\t\t\tif (this.options.coordinateOutput === 'relative') return raw;\n\t\t\traw.x /= rect.width;\n\t\t\traw.y /= rect.height;\n\t\t\treturn raw;\n\t\t},\n\n\t\tdispatch: <N extends keyof Events<T>>(\n\t\t\t...args: undefined extends Events<T>[N] ? [N] : [N, Events<T>[N]]\n\t\t) => {\n\t\t\tconst name = args[0];\n\t\t\tconst e = args[1];\n\t\t\tlet lastResult: boolean | Events<T>[N] = true;\n\t\t\tfor (const value of Object.values(this.#modules)) {\n\t\t\t\tif (!value.modifiers || !(name in value.modifiers)) continue;\n\t\t\t\tlastResult =\n\t\t\t\t\te === undefined\n\t\t\t\t\t\t? (value.modifiers[name] as () => boolean)()\n\t\t\t\t\t\t: (\n\t\t\t\t\t\t\t\tvalue.modifiers[name] as (\n\t\t\t\t\t\t\t\t\tdetail?: Events<T>[N],\n\t\t\t\t\t\t\t\t) => boolean | Events<T>[N]\n\t\t\t\t\t\t\t)(e);\n\t\t\t\tif (lastResult === false) return;\n\t\t\t}\n\t\t\tlet event: Events<T>[N];\n\t\t\tif (lastResult === true) event = e as Events<T>[N];\n\t\t\telse event = lastResult;\n\t\t\tthis.#subscribers[name]?.forEach((listener) => listener(event));\n\t\t},\n\n\t\taugment: (aug: GeneralObject) => {\n\t\t\tObject.entries(aug).forEach(([key, value]) => (this[key as '_augmentSlot'] = value));\n\t\t},\n\t};\n\n\tdispatch = this.moduleUtils.dispatch;\n\n\t#runHooks<K extends HookKeys>(field: K, ...args: Parameters<Required<BaseModule>[K]>) {\n\t\tObject.values(this.#modules).forEach((module) => {\n\t\t\tconst hook = module[field];\n\t\t\t// oxlint-disable-next-line typescript/no-explicit-any\n\t\t\tif (hook) hook(...(args as any));\n\t\t});\n\t}\n\n\t#onPointerDown = (e: PointerEvent) => {\n\t\tif (this.#pointers.size >= 2) return;\n\t\tif (e.isPrimary) this.#pointers.clear();\n\t\tconst pointer = {\n\t\t\trecords: [{ x: e.clientX, y: e.clientY, timestamp: Date.now() }],\n\t\t\ttarget: e.target,\n\t\t};\n\t\tthis.#pointers.set(e.pointerId, pointer);\n\t\tthis.#runHooks('onPointerDown', e, pointer, this.#pointers);\n\t};\n\n\t#onPointerMove = (e: PointerEvent) => {\n\t\tconst pointer = this.#pointers.get(e.pointerId);\n\t\tif (!pointer) return;\n\t\tpointer.records.push({ x: e.clientX, y: e.clientY, timestamp: Date.now() });\n\t\tthis.#runHooks('onPointerMove', e, pointer, this.#pointers);\n\t};\n\n\t#onPointerUp = (e: PointerEvent) => {\n\t\tconst pointer = this.#pointers.get(e.pointerId);\n\t\tif (!pointer) return;\n\t\tthis.#pointers.delete(e.pointerId);\n\t\tthis.#runHooks('onPointerUp', e, pointer, this.#pointers);\n\t};\n\n\t#onWheel = (e: WheelEvent) => this.#runHooks('onWheel', e);\n\n\tstop = (toStop?: Reloadable<T>) => {\n\t\tconst stopPointeract = () => {\n\t\t\tthis.#element.removeEventListener('pointerdown', this.#onPointerDown);\n\t\t\tthis.#window.removeEventListener('pointermove', this.#onPointerMove);\n\t\t\tthis.#window.removeEventListener('pointerup', this.#onPointerUp);\n\t\t\tthis.#element.removeEventListener('wheel', this.#onWheel);\n\t\t\tthis.#runHooks('onStop');\n\t\t};\n\t\tconst stopModule = (moduleCtor: ModuleCtor) => {\n\t\t\tif (!(moduleCtor.name in this.#modules)) return;\n\t\t\tconst module = this.#modules[moduleCtor.name];\n\t\t\tif (module.onStop) module.onStop();\n\t\t\tthis.#pausedModules[moduleCtor.name] = module;\n\t\t\tdelete this.#modules[moduleCtor.name];\n\t\t};\n\t\tif (!toStop) stopPointeract();\n\t\telse\n\t\t\ttoStop.forEach((module) => {\n\t\t\t\tstopModule(module);\n\t\t\t});\n\t\treturn this;\n\t};\n\n\tstart = (toStart?: Reloadable<T>) => {\n\t\tconst startPointeract = () => {\n\t\t\tthis.#element.addEventListener('pointerdown', this.#onPointerDown);\n\t\t\tthis.#window.addEventListener('pointermove', this.#onPointerMove);\n\t\t\tthis.#window.addEventListener('pointerup', this.#onPointerUp);\n\t\t\tthis.#element.addEventListener('wheel', this.#onWheel, { passive: false });\n\t\t\tthis.#runHooks('onStart');\n\t\t};\n\t\tconst startModule = (moduleCtor: ModuleCtor) => {\n\t\t\tif (!(moduleCtor.name in this.#pausedModules)) return;\n\t\t\tconst module = this.#pausedModules[moduleCtor.name];\n\t\t\tif (module.onStart) module.onStart();\n\t\t\tthis.#modules[moduleCtor.name] = module;\n\t\t\tdelete this.#pausedModules[moduleCtor.name];\n\t\t};\n\t\tif (!toStart) startPointeract();\n\t\telse\n\t\t\ttoStart.forEach((module) => {\n\t\t\t\tstartModule(module);\n\t\t\t});\n\t\treturn this;\n\t};\n\n\tdispose = () => {\n\t\tthis.stop();\n\t\tthis.#_window = null;\n\t\tthis.#runHooks('dispose');\n\t\tthis.#subscribers = {};\n\t};\n}\n\ntype PointeractType = new <M extends ModuleInputCtor = []>(\n\t...args: ConstructorParameters<typeof Pointeract<M>>\n) => Pointeract<M> & Augmentation<M>;\n\nexport type PointeractInterface<M extends ModuleInput = []> = Pointeract<never> & Augmentation<M>;\n\nexport default Pointeract as PointeractType;\n"],"names":["BaseModule","constructor","utils","window","pointers","element","options","this","getNthPointer","toTargetCoords","augment","dispatch","onPointerDown","onPointerUp","onPointerMove","onWheel","onStart","onStop","dispose","modifiers","getLast","arr","num","length","Click","lastClickTime","Infinity","clickSteak","_e","pointer","size","interrupted","e","threshold","moveThreshold","Math","abs","records","x","clientX","y","clientY","newLast","timestamp","time","clickPreserveTime","coords","target","streak","Drag","last","dx","dy","deltaX","deltaY","MultitouchPanZoom","pinchZoomState","lastDistance","lastMidpoint","getPointerDistance","pointer0Coords","pointer1Coords","sqrt","getPointerMidpoint","_pointer","newDistance","newMidpointOnScreen","zoomFactor","newMidpoint","dispatchPanEvent","dispatchZoomEvent","factor","origin","diff","PreventDefault","preventDefault","preventDefaultFunction","style","touchAction","addEventListener","passive","removeEventListener","wheelPanZoom","args","super","patch","k","v","Object","entries","fillIn","proControlSchema","lockControlSchema","ctrlKey","shiftKey","scaleFactor","Lubricator","states","animationId","lubricatee","lubricator","forEach","key","value","sample","fields","keys","field","catch","release","makeLubricate","requestAnimationFrame","perFrame","cancelAnimationFrame","values","detail","lubricated","accumulate","stateFields","optionsFields","config","countType","event","perEventStates","needEmit","type","absDiff","delta","reciprocalAbs","diminishBoundary","decayFactor","pow","panPreset","dragPreset","zoomPreset","Pointeract","Map","modules","pausedModules","_window","subscribers","Error","_modules","ownerDocument","defaultView","coordinateOutput","module","instance","moduleUtils","assign","name","on","listener","Set","add","off","delete","n","error","i","raw","rect","getBoundingClientRect","left","top","width","height","lastResult","aug","runHooks","hook","isPrimary","clear","Date","now","set","pointerId","get","push","stop","toStop","stopModule","moduleCtor","stopPointeract","start","toStart","startModule","startPointeract"],"mappings":"AA8BA,MAAqBA,EAepB,WAAAC,CACCC,EACUC,EACAC,EACAC,EACVC,GAHUC,KAAAJ,OAAAA,EACAI,KAAAH,SAAAA,EACAG,KAAAF,QAAAA,EAGVE,KAAKC,cAAgBN,EAAMM,cAC3BD,KAAKE,eAAiBP,EAAMO,eAC5BF,KAAKG,QAAUR,EAAMQ,QACr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,QAAQiI,EAAOjI,SAC1BV,MAAKmI,EAAe4C,EAAWhC,MAAQJ,SAChC3I,MAAKkI,EAAS6C,EAAWhC,OAOjC,OALK8B,EAEJA,EAAO/E,QAAS6C,IACfmC,EAAWnC,KAjBU,MACtB3I,MAAKF,EAAS4E,oBAAoB,cAAe1E,MAAKK,GACtDL,MAAKJ,EAAQ8E,oBAAoB,cAAe1E,MAAKO,GACrDP,MAAKJ,EAAQ8E,oBAAoB,YAAa1E,MAAKM,GACnDN,MAAKF,EAAS4E,oBAAoB,QAAS1E,MAAKQ,GAChDR,MAAKkK,EAAU,WASHc,GAKNhL,MAGRiL,MAASC,IACR,MAOMC,EAAeJ,IACpB,KAAMA,EAAWhC,QAAQ/I,MAAKmI,GAAiB,OAC/C,MAAMQ,EAAS3I,MAAKmI,EAAe4C,EAAWhC,MAC1CJ,EAAOlI,SAASkI,EAAOlI,UAC3BT,MAAKkI,EAAS6C,EAAWhC,MAAQJ,SAC1B3I,MAAKmI,EAAe4C,EAAWhC,OAOvC,OALKmC,EAEJA,EAAQpF,QAAS6C,IAChBwC,EAAYxC,KAjBU,MACvB3I,MAAKF,EAAS0E,iBAAiB,cAAexE,MAAKK,GACnDL,MAAKJ,EAAQ4E,iBAAiB,cAAexE,MAAKO,GAClDP,MAAKJ,EAAQ4E,iBAAiB,YAAaxE,MAAKM,GAChDN,MAAKF,EAAS0E,iBAAiB,QAASxE,MAAKQ,EAAU,CAAEiE,SAAS,IAClEzE,MAAKkK,EAAU,YASFkB,GAKPpL,MAGRW,QAAU,KACTX,KAAK4K,OACL5K,MAAKoI,EAAW,KAChBpI,MAAKkK,EAAU,WACflK,MAAKqI,EAAe,CAAA"}
@@ -1,13 +1,13 @@
1
- import type { BaseOptions, GeneralObject, Pointer, Pointers, StdEvents, Constrain } from './declarations';
2
- import type { Pointeract, PointeractInterface } from './pointeract';
1
+ import type { Pointeract, PointeractInterface } from './Pointeract';
2
+ import type { BaseOptions, GeneralObject, Pointer, Pointers, StdEvents, ModuleInput as MI, Orchestratable, General } from './types';
3
3
  export type HookKeys = 'onPointerDown' | 'onPointerUp' | 'onPointerMove' | 'onWheel' | 'onStart' | 'onStop' | 'dispose';
4
- export type BaseArgs = [
5
- Pointeract<[]>['moduleUtils'],
6
- Window,
7
- Pointers,
8
- HTMLElement,
9
- GeneralObject
10
- ];
4
+ export type BaseArgs = ConstructorParameters<typeof BaseModule>;
5
+ export type ModuleCtor = typeof BaseModule<General, General, General>;
6
+ export type ModuleInput = MI<ModuleCtor>;
7
+ export type ModuleInputCtor = ReadonlyArray<ModuleCtor>;
8
+ export type Options<T extends ModuleInput = []> = Orchestratable<T, 'options'> & BaseOptions;
9
+ export type Events<T extends ModuleInput = []> = Orchestratable<T, '_Events'> & StdEvents;
10
+ export type Augmentation<T extends ModuleInput = []> = Orchestratable<T, '_Augmentation'>;
11
11
  export default class BaseModule<O extends BaseOptions = BaseOptions, E extends StdEvents = StdEvents, A extends {} = {}> {
12
12
  protected window: Window;
13
13
  protected pointers: Pointers;
@@ -18,7 +18,7 @@ export default class BaseModule<O extends BaseOptions = BaseOptions, E extends S
18
18
  protected getNthPointer: Pointeract<[]>['moduleUtils']['getNthPointer'];
19
19
  protected toTargetCoords: Pointeract<[]>['moduleUtils']['toTargetCoords'];
20
20
  protected augment: (augmentation: A) => void;
21
- protected dispatch: <K extends keyof Constrain<E>>(...arg: undefined extends E[K] ? [K] : [K, E[K]]) => void;
21
+ protected dispatch: <K extends keyof E>(...arg: undefined extends E[K] ? [K] : [K, E[K]]) => void;
22
22
  options: O;
23
23
  constructor(utils: PointeractInterface['moduleUtils'], window: Window, pointers: Pointers, element: HTMLElement, options: GeneralObject);
24
24
  onPointerDown?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;
@@ -29,6 +29,6 @@ export default class BaseModule<O extends BaseOptions = BaseOptions, E extends S
29
29
  onStop?: () => void;
30
30
  dispose?: () => void;
31
31
  modifiers?: {
32
- [K in keyof Constrain<E>]?: (event: E[K]) => boolean | E[K];
32
+ [K in keyof E]?: (event: E[K]) => boolean | E[K];
33
33
  };
34
34
  }
@@ -1,4 +1,5 @@
1
- import type { Augmentation, Events, ModuleInput, ModuleInputCtor, Options, Reloadable } from './declarations';
1
+ import type { Augmentation, Events, Options, ModuleInputCtor, ModuleInput } from './BaseModule';
2
+ type Reloadable<T extends ModuleInputCtor> = Array<T[number]>;
2
3
  export declare class Pointeract<T extends ModuleInputCtor = []> {
3
4
  #private;
4
5
  options: Options<T>;
@@ -8,8 +9,8 @@ export declare class Pointeract<T extends ModuleInputCtor = []> {
8
9
  off<K extends keyof Events<T>>(type: K, listener: (event: Events<T>[K]) => void): this;
9
10
  private moduleUtils;
10
11
  dispatch: <N extends keyof Events<T>>(...args: undefined extends Events<T>[N] ? [N] : [N, Events<T>[N]]) => void;
11
- stop: (_toStop?: Reloadable<T>) => this;
12
- start: (_toStart?: Reloadable<T>) => this;
12
+ stop: (toStop?: Reloadable<T>) => this;
13
+ start: (toStart?: Reloadable<T>) => this;
13
14
  dispose: () => void;
14
15
  }
15
16
  type PointeractType = new <M extends ModuleInputCtor = []>(...args: ConstructorParameters<typeof Pointeract<M>>) => Pointeract<M> & Augmentation<M>;
@@ -1,9 +1,9 @@
1
- export { default as BaseModule, type BaseArgs } from './baseModule';
2
- export type { Options, Events, Pointer, Pointers, StdEvents, BaseOptions } from './declarations';
3
- export { default as Click } from './modules/click';
4
- export { default as Drag } from './modules/drag';
5
- export { default as MultitouchPanZoom } from './modules/multitouchPanZoom';
6
- export { default as PreventDefault } from './modules/preventDefault';
7
- export { default as WheelPanZoom } from './modules/wheelPanZoom';
8
- export { default as Lubricator, panPreset, dragPreset, zoomPreset } from './modules/lubricator';
9
- export { default as Pointeract, type PointeractInterface } from './pointeract';
1
+ export { default as BaseModule, type BaseArgs, type Options, type Events } from './BaseModule';
2
+ export type { Pointer, Pointers, StdEvents, BaseOptions } from './types';
3
+ export { default as Click } from './modules/Click';
4
+ export { default as Drag } from './modules/Drag';
5
+ export { default as MultitouchPanZoom } from './modules/MultitouchPanZoom';
6
+ export { default as PreventDefault } from './modules/PreventDefault';
7
+ export { default as WheelPanZoom } from './modules/WheelPanZoom';
8
+ export { default as Lubricator, panPreset, dragPreset, zoomPreset } from './modules/Lubricator';
9
+ export { default as Pointeract, type PointeractInterface } from './Pointeract';
@@ -1,5 +1,5 @@
1
- import type { BaseOptions, Pointer, Pointers } from '../declarations';
2
- import BaseModule from '../baseModule';
1
+ import type { BaseOptions, Pointer, Pointers } from '../types';
2
+ import BaseModule from '../BaseModule';
3
3
  interface Options extends BaseOptions {
4
4
  clickPreserveTime?: number;
5
5
  moveThreshold?: number;
@@ -1,5 +1,5 @@
1
- import type { Pointer, Pointers } from '../declarations';
2
- import BaseModule from '../baseModule';
1
+ import type { Pointer, Pointers } from '../types';
2
+ import BaseModule from '../BaseModule';
3
3
  export default class Drag extends BaseModule {
4
4
  onPointerMove: (e: PointerEvent, pointer: Pointer, pointers: Pointers) => void;
5
5
  }
@@ -1,5 +1,5 @@
1
- import BaseModule, { BaseArgs } from '../baseModule';
2
- import { BaseOptions } from '../declarations';
1
+ import BaseModule, { BaseArgs } from '../BaseModule';
2
+ import { BaseOptions } from '../types';
3
3
  interface Options extends BaseOptions {
4
4
  lubricator?: Record<string, PerEventOption>;
5
5
  }
@@ -1,5 +1,5 @@
1
- import type { Pointer, Pointers } from '../declarations';
2
- import BaseModule from '../baseModule';
1
+ import type { Pointer, Pointers } from '../types';
2
+ import BaseModule from '../BaseModule';
3
3
  export default class MultitouchPanZoom extends BaseModule {
4
4
  #private;
5
5
  onPointerDown: (_e: PointerEvent, _pointer: Pointer, pointers: Pointers) => void;
@@ -1,4 +1,4 @@
1
- import BaseModule from '../baseModule';
1
+ import BaseModule from '../BaseModule';
2
2
  export default class PreventDefault extends BaseModule {
3
3
  #private;
4
4
  onWheel: (e: WheelEvent) => void;
@@ -1,5 +1,5 @@
1
- import type { BaseOptions } from '../declarations';
2
- import BaseModule, { BaseArgs } from '../baseModule';
1
+ import type { BaseOptions } from '../types';
2
+ import BaseModule, { BaseArgs } from '../BaseModule';
3
3
  interface Options extends BaseOptions {
4
4
  proControlSchema?: boolean;
5
5
  zoomFactor?: number;
@@ -0,0 +1,49 @@
1
+ export type General = any;
2
+ export type GeneralArray = ReadonlyArray<General>;
3
+ export type GeneralObject = object;
4
+ export type GeneralDictionary = Record<Indexable, General>;
5
+ export type GeneralConstructor = new (...args: General[]) => General;
6
+ type Indexable = string | number | symbol;
7
+ type UnionToIntersection<U> = (U extends General ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
8
+ type GeneralModuleInput = ReadonlyArray<GeneralConstructor> | ReadonlyArray<GeneralObject>;
9
+ export type ModuleInput<T extends GeneralConstructor> = ReadonlyArray<T> | ReadonlyArray<InstanceType<T>>;
10
+ type Instances<T extends GeneralModuleInput> = T extends ReadonlyArray<GeneralConstructor> ? InstanceType<T[number]> : T[number];
11
+ export type Orchestratable<T extends GeneralModuleInput, K extends keyof Instances<T>> = UnionToIntersection<Instances<T>[K]>;
12
+ export type Coordinates = {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ export type Pointers = Map<number, Pointer>;
17
+ export type Pointer = {
18
+ records: Array<{
19
+ x: number;
20
+ y: number;
21
+ timestamp: number;
22
+ }>;
23
+ target: EventTarget | null;
24
+ [key: Indexable]: General;
25
+ };
26
+ export interface StdEvents {
27
+ pan: {
28
+ deltaX: number;
29
+ deltaY: number;
30
+ };
31
+ drag: {
32
+ deltaX: number;
33
+ deltaY: number;
34
+ x: number;
35
+ y: number;
36
+ };
37
+ trueClick: Coordinates & {
38
+ target: EventTarget | null;
39
+ streak: number;
40
+ };
41
+ zoom: Coordinates & {
42
+ factor: number;
43
+ };
44
+ }
45
+ export interface BaseOptions {
46
+ coordinateOutput?: 'absolute' | 'relative' | 'relativeFraction';
47
+ element: HTMLElement;
48
+ }
49
+ export {};
@@ -1,4 +1,3 @@
1
- import { GeneralObject } from './declarations';
1
+ import { GeneralDictionary } from './types';
2
2
  export declare function getLast<T>(arr: Array<T>, num?: number): T;
3
- export declare function fillIn(patch: GeneralObject, target: GeneralObject): void;
4
- export declare function toArray<T>(toTrans: T | Array<T>): T[];
3
+ export declare function fillIn(patch: GeneralDictionary, target: GeneralDictionary): void;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "pointeract",
3
- "version": "1.1.0",
4
- "description": "Modern, lightweight, robust and extensible user gesture recognizer.",
3
+ "version": "1.1.2",
4
+ "description": "A 3KB, tree-shakable, TypeScript-native alternative to Hammer.js for robust pan/zoom gestures runtime-flexible and extensible.",
5
5
  "keywords": [
6
6
  "frontend",
7
- "interaction",
8
- "pointer-events",
7
+ "gesture-detection",
8
+ "lightweight",
9
+ "pan-zoom",
9
10
  "typescript"
10
11
  ],
11
12
  "homepage": "https://pointeract.consensia.cc",
@@ -26,29 +27,32 @@
26
27
  ],
27
28
  "type": "module",
28
29
  "sideEffects": false,
29
- "main": "./dist/index.cjs",
30
+ "main": "./dist/index.js",
30
31
  "module": "./dist/index.js",
31
32
  "types": "./dist/types/index.d.ts",
33
+ "unpkg": "./dist/index.js",
34
+ "jsdelivr": "./dist/index.js",
32
35
  "publishConfig": {
33
36
  "access": "public",
34
37
  "provenance": true
35
38
  },
36
39
  "devDependencies": {
37
- "@types/node": "^25.2.0",
40
+ "@types/node": "^25.3.0",
38
41
  "@vitest/coverage-v8": "^4.0.18",
39
- "happy-dom": "^20.5.0",
40
- "oxfmt": "^0.28.0",
41
- "oxlint": "^1.43.0",
42
- "oxlint-tsgolint": "^0.11.4",
42
+ "happy-dom": "^20.7.0",
43
+ "oxfmt": "^0.35.0",
44
+ "oxlint": "^1.50.0",
45
+ "oxlint-tsgolint": "^0.14.2",
43
46
  "terser": "^5.46.0",
44
47
  "tsc-alias": "^1.8.16",
45
48
  "typescript": "^5.9.3",
46
49
  "vite": "^7.3.1",
47
50
  "vitepress": "2.0.0-alpha.16",
48
51
  "vitepress-plugin-group-icons": "^1.7.1",
52
+ "vitepress-theme-trito": "^1.0.6",
49
53
  "vitest": "^4.0.18",
50
- "vue": "^3.5.27",
51
- "vue-tsc": "^3.2.4"
54
+ "vue": "^3.5.28",
55
+ "vue-tsc": "^3.2.5"
52
56
  },
53
57
  "scripts": {
54
58
  "build": "vite build && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
package/dist/index.cjs DELETED
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class t{constructor(t,e,s,i,o){this.window=e,this.pointers=s,this.element=i,this.getNthPointer=t.getNthPointer,this.toTargetCoords=t.toTargetCoords,this.augment=t.augment,this.dispatch=t.dispatch,this.options=o}getNthPointer;toTargetCoords;augment;dispatch;options;onPointerDown;onPointerUp;onPointerMove;onWheel;onStart;onStop;dispose;modifiers}function e(t,e=0){return t[t.length-1-e]}function s(t){return Array.isArray(t)?t:[t]}const i={decayFactor:.25,fields:{deltaX:{countType:"sum",diminishBoundary:.5},deltaY:{countType:"sum",diminishBoundary:.5}}},o=i;exports.BaseModule=t,exports.Click=class extends t{#t=-1/0;#e=0;onPointerDown=(t,e,s)=>{if(2===s.size){this.getNthPointer(0).interrupted=!0,e.interrupted=!0}};onPointerUp=(t,s)=>{if(s.interrupted)return;const i=this.options.moveThreshold??5;if(Math.abs(s.records[0].x-t.clientX)>=i||Math.abs(s.records[0].y-t.clientY)>=i)return;const o=e(s.records).timestamp,n=this.options.clickPreserveTime??400;o-this.#t<=n?this.#e++:this.#e=1,this.#t=o;const r=this.toTargetCoords({x:t.clientX,y:t.clientY});this.dispatch("trueClick",{...r,target:s.target,streak:this.#e})}},exports.Drag=class extends t{onPointerMove=(t,s,i)=>{const o=e(s.records,1);if(1===i.size){const e=t.clientX-o.x,s=t.clientY-o.y;this.dispatch("drag",{deltaX:e,deltaY:s,x:t.clientX,y:t.clientY})}}},exports.Lubricator=class extends t{#s={};#i=null;constructor(...t){super(...t);const e=this.options.lubricator;e&&Object.entries(e).forEach(([t,e])=>{const s={sample:{},fields:{}};Object.keys(e.fields).forEach(t=>{s.fields[t]={catch:1,release:1}}),this.#s[t]=s,this.modifiers[t]=this.#o(s,e)})}onStart=()=>{this.#i=requestAnimationFrame(this.#n)};onStop=()=>{this.#i&&cancelAnimationFrame(this.#i),this.#i=null,Object.values(this.#s).forEach(t=>{Object.values(t.fields).forEach(t=>{t.release=1,t.catch=1})})};#o=(t,e)=>s=>!!s.lubricated||(t.sample=s,this.#r(t.fields,e.fields,s),!1);#r=(t,e,s)=>{Object.entries(t).forEach(([t,i])=>{if("number"!=typeof s[t])return;const o=e[t].countType;"sum"===o?i.catch+=s[t]:"product"===o&&(i.catch*=s[t])})};#n=()=>{const t=this.#s,e=this.options.lubricator;e&&(Object.entries(t).forEach(([t,s])=>{const i=s.sample;i.lubricated=!0;let o=!1;for(const[n,r]of Object.entries(s.fields)){if(1===r.catch)continue;const s=e[t].fields[n].countType;let a,h,c;("sum"===s?(h=r.catch-r.release,a=Math.abs(h)):(h=r.catch/r.release,a=this.#a(h)-1),a<=e[t].fields[n].diminishBoundary)?(o||(o=!0),i[n]=h,r.release=1,r.catch=1):("sum"===s?(c=h*e[t].decayFactor,r.release+=c):(c=Math.pow(h,e[t].decayFactor),r.release*=c),i[n]=c,o=!0)}o&&this.dispatch(t,i)}),this.#i=requestAnimationFrame(this.#n))};#a=t=>t>1?t:1/t;modifiers={}},exports.MultitouchPanZoom=class extends t{#h={lastDistance:0,lastMidpoint:{x:0,y:0}};#c(){const t=e(this.getNthPointer(0).records),s=e(this.getNthPointer(1).records),i=t.x-s.x,o=t.y-s.y;return Math.sqrt(i*i+o*o)}#d(){const t=e(this.getNthPointer(0).records),s=e(this.getNthPointer(1).records);return{x:(t.x+s.x)/2,y:(t.y+s.y)/2}}onPointerDown=(t,e,s)=>{2===s.size&&(this.#h.lastDistance=this.#c(),this.#h.lastMidpoint=this.toTargetCoords(this.#d()))};onPointerMove=(t,e,s)=>{if(2===s.size){const t=this.#c(),e=this.#d(),s=t/this.#h.lastDistance;this.#h.lastDistance=t;const i=this.toTargetCoords(e),o=i.x-this.#h.lastMidpoint.x,n=i.y-this.#h.lastMidpoint.y;this.#h.lastMidpoint=i,this.#l({deltaX:o,deltaY:n}),this.#p(s,i)}};#p(t,e){this.dispatch("zoom",{x:e.x,y:e.y,factor:t})}#l(t){this.dispatch("pan",t)}},exports.Pointeract=class{#u;#m=new Map;#f={};#v={};#P;#g={};options;get#w(){if(!this.#P)throw new Error("[Pointeract] Window is not defined.");return this.#P}constructor(t,e){const i=s(e||[]);this.#P=t.element.ownerDocument.defaultView,this.#u=t.element,t.coordinateOutput||(t.coordinateOutput="relative"),this.options=t,i.forEach(e=>{const s=new e(this.moduleUtils,this.#w,this.#m,this.#u,this.options);Object.assign(s,{options:t}),this.#f[e.name]=s})}on=(t,e)=>(this.#g[t]||(this.#g[t]=new Set),this.#g[t]?.add(e),this);off(t,e){return this.#g[t]?.delete(e),this}moduleUtils={getNthPointer:t=>{const e=new Error("[Pointeract] Invalid pointer index.");if(t<0||t>=this.#m.size)throw e;let s=0;for(const i of this.#m.values()){if(s===t)return i;s++}throw e},toTargetCoords:t=>{if("absolute"===this.options.coordinateOutput)return t;const e=this.#u.getBoundingClientRect();return t.x-=e.left,t.y-=e.top,"relative"===this.options.coordinateOutput||(t.x/=e.width,t.y/=e.height),t},dispatch:(...t)=>{const e=t[0],s=t[1];let i,o=!0;for(const n of Object.values(this.#f))if(n.modifiers&&e in n.modifiers&&(o=void 0===s?n.modifiers[e]():n.modifiers[e](s),!1===o))return;i=!0===o?s:o,this.#g[e]?.forEach(t=>t(i))},augment:t=>{Object.entries(t).forEach(([t,e])=>this[t]=e)}};dispatch=this.moduleUtils.dispatch;#y(t,...e){Object.values(this.#f).forEach(s=>{const i=s[t];i&&i(...e)})}#b=t=>{if(this.#m.size>=2)return;t.isPrimary&&this.#m.clear();const e={records:[{x:t.clientX,y:t.clientY,timestamp:Date.now()}],target:t.target};this.#m.set(t.pointerId,e),this.#y("onPointerDown",t,e,this.#m)};#x=t=>{const e=this.#m.get(t.pointerId);e&&(e.records.push({x:t.clientX,y:t.clientY,timestamp:Date.now()}),this.#y("onPointerMove",t,e,this.#m))};#E=t=>{const e=this.#m.get(t.pointerId);e&&(this.#m.delete(t.pointerId),this.#y("onPointerUp",t,e,this.#m))};#S=t=>this.#y("onWheel",t);stop=t=>{const e=t=>{if(!(t.name in this.#f))return;const e=this.#f[t.name];e.onStop&&e.onStop(),this.#v[t.name]=e,delete this.#f[t.name]};return t?s(t).forEach(t=>{e(t)}):(()=>{this.#u.removeEventListener("pointerdown",this.#b),this.#w.removeEventListener("pointermove",this.#x),this.#w.removeEventListener("pointerup",this.#E),this.#u.removeEventListener("wheel",this.#S),this.#y("onStop")})(),this};start=t=>{const e=t=>{if(!(t.name in this.#v))return;const e=this.#v[t.name];e.onStart&&e.onStart(),this.#f[t.name]=e,delete this.#v[t.name]};return t?s(t).forEach(t=>{e(t)}):(()=>{this.#u.addEventListener("pointerdown",this.#b),this.#w.addEventListener("pointermove",this.#x),this.#w.addEventListener("pointerup",this.#E),this.#u.addEventListener("wheel",this.#S,{passive:!1}),this.#y("onStart")})(),this};dispose=()=>{this.stop(),this.#P=null,this.#y("dispose"),this.#g={}}},exports.PreventDefault=class extends t{onWheel=t=>t.preventDefault();#M=t=>t.preventDefault();onStart=()=>{this.element.style.touchAction="none",this.element.addEventListener("gesturestart",this.#M,{passive:!1}),this.element.addEventListener("gesturechange",this.#M,{passive:!1})};onStop=()=>{this.element.style.touchAction="",this.element.removeEventListener("gesturestart",this.#M),this.element.removeEventListener("gesturechange",this.#M)};dispose=this.onStop},exports.WheelPanZoom=class extends t{constructor(...t){super(...t),function(t,e){for(const[s,i]of Object.entries(t))s in e||(e[s]=i)}({proControlSchema:!1,zoomFactor:.1,lockControlSchema:!1},this.options)}onWheel=t=>{const e=this.options;if(e.proControlSchema||e.lockControlSchema||!(t.ctrlKey||t.shiftKey||Math.abs(t.deltaX)>Math.abs(t.deltaY))||(e.proControlSchema=!0),e.proControlSchema)if(t.ctrlKey){const s=1-e.zoomFactor*t.deltaY,i=this.toTargetCoords({x:t.clientX,y:t.clientY});this.#p(s,i)}else t.shiftKey&&Math.abs(t.deltaX)<=Math.abs(t.deltaY)?this.#l({deltaX:-t.deltaY,deltaY:-t.deltaX}):this.#l({deltaX:-t.deltaX,deltaY:-t.deltaY});else{const s=1-e.zoomFactor/20*t.deltaY,i=this.toTargetCoords({x:t.clientX,y:t.clientY});this.#p(s,i)}};#p(t,e){this.dispatch("zoom",{x:e.x,y:e.y,factor:t})}#l(t){this.dispatch("pan",t)}},exports.dragPreset=o,exports.panPreset=i,exports.zoomPreset={decayFactor:.25,fields:{factor:{countType:"product",diminishBoundary:.01}}};
2
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/baseModule.ts","../src/utils.ts","../src/modules/lubricator.ts","../src/modules/click.ts","../src/modules/drag.ts","../src/modules/multitouchPanZoom.ts","../src/pointeract.ts","../src/modules/preventDefault.ts","../src/modules/wheelPanZoom.ts"],"sourcesContent":["import type {\n\tBaseOptions,\n\tGeneralObject,\n\tPointer,\n\tPointers,\n\tStdEvents,\n\tConstrain,\n} from '@/declarations';\nimport type { Pointeract, PointeractInterface } from '@/pointeract';\n\nexport type HookKeys =\n\t| 'onPointerDown'\n\t| 'onPointerUp'\n\t| 'onPointerMove'\n\t| 'onWheel'\n\t| 'onStart'\n\t| 'onStop'\n\t| 'dispose';\n\nexport type BaseArgs = [\n\tPointeract<[]>['moduleUtils'],\n\tWindow,\n\tPointers,\n\tHTMLElement,\n\tGeneralObject,\n];\n\nexport default class BaseModule<\n\tO extends BaseOptions = BaseOptions,\n\tE extends StdEvents = StdEvents,\n\tA extends {} = {},\n> {\n\tdeclare private static readonly _BaseModuleBrand: unique symbol; // Nominal marker\n\tdeclare readonly _Events: E;\n\tdeclare readonly _Augmentation: A;\n\tprotected getNthPointer: Pointeract<[]>['moduleUtils']['getNthPointer'];\n\tprotected toTargetCoords: Pointeract<[]>['moduleUtils']['toTargetCoords'];\n\tprotected augment: (augmentation: A) => void;\n\tprotected dispatch: <K extends keyof Constrain<E>>(\n\t\t...arg: undefined extends E[K] ? [K] : [K, E[K]]\n\t) => void;\n\toptions: O;\n\tconstructor(\n\t\tutils: PointeractInterface['moduleUtils'],\n\t\tprotected window: Window,\n\t\tprotected pointers: Pointers,\n\t\tprotected element: HTMLElement,\n\t\toptions: GeneralObject,\n\t) {\n\t\tthis.getNthPointer = utils.getNthPointer;\n\t\tthis.toTargetCoords = utils.toTargetCoords;\n\t\tthis.augment = utils.augment;\n\t\tthis.dispatch = utils.dispatch as typeof this.dispatch;\n\t\tthis.options = options;\n\t}\n\n\tonPointerDown?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;\n\tonPointerUp?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;\n\tonPointerMove?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;\n\tonWheel?: (...args: [event: WheelEvent]) => void;\n\tonStart?: () => void;\n\tonStop?: () => void;\n\tdispose?: () => void;\n\tmodifiers?: {\n\t\t[K in keyof Constrain<E>]?: (event: E[K]) => boolean | E[K];\n\t};\n}\n","import { GeneralObject } from '@/declarations';\n\nexport function getLast<T>(arr: Array<T>, num: number = 0) {\n\treturn arr[arr.length - 1 - num];\n}\n\nexport function fillIn(patch: GeneralObject, target: GeneralObject) {\n\tfor (const [k, v] of Object.entries(patch)) if (!(k in target)) target[k] = v;\n}\n\nexport function toArray<T>(toTrans: T | Array<T>) {\n\treturn Array.isArray(toTrans) ? toTrans : [toTrans];\n}\n","import BaseModule, { BaseArgs } from '@/baseModule';\nimport { BaseOptions, Events, GeneralObject } from '@/declarations';\n\ninterface Options extends BaseOptions {\n\tlubricator?: Record<string, PerEventOption>;\n}\n\ntype PerEventOption = {\n\tdecayFactor: number;\n\tfields: Record<string, { countType: 'sum' | 'product'; diminishBoundary: number }>;\n};\n\ntype PerEventStates = {\n\tsample: GeneralObject;\n\tfields: Record<\n\t\tstring,\n\t\t{\n\t\t\tcatch: number;\n\t\t\trelease: number;\n\t\t}\n\t>;\n};\n\nexport default class Lubricator extends BaseModule<Options> {\n\t#states: Record<string, PerEventStates> = {};\n\t#animationId: number | null = null;\n\n\tconstructor(...args: BaseArgs) {\n\t\tsuper(...args);\n\t\tconst lubricatee = this.options.lubricator;\n\t\tif (!lubricatee) return;\n\t\tObject.entries(lubricatee).forEach(([key, value]) => {\n\t\t\t// per event scope\n\t\t\tconst states = {\n\t\t\t\tsample: {},\n\t\t\t\tfields: {},\n\t\t\t} as PerEventStates;\n\t\t\tObject.keys(value.fields).forEach((field) => {\n\t\t\t\tstates.fields[field] = {\n\t\t\t\t\tcatch: 1,\n\t\t\t\t\trelease: 1,\n\t\t\t\t};\n\t\t\t});\n\t\t\tthis.#states[key] = states;\n\t\t\tthis.modifiers[key] = this.#makeLubricate(states, value);\n\t\t});\n\t}\n\n\tonStart = () => {\n\t\tthis.#animationId = requestAnimationFrame(this.#perFrame);\n\t};\n\n\tonStop = () => {\n\t\tif (this.#animationId) cancelAnimationFrame(this.#animationId);\n\t\tthis.#animationId = null;\n\t\tObject.values(this.#states).forEach((value) => {\n\t\t\t// per event scope\n\t\t\tObject.values(value.fields).forEach((value) => {\n\t\t\t\t// per field scope\n\t\t\t\tvalue.release = 1;\n\t\t\t\tvalue.catch = 1;\n\t\t\t});\n\t\t});\n\t};\n\n\t#makeLubricate =\n\t\t(states: PerEventStates, options: PerEventOption) => (detail: GeneralObject) => {\n\t\t\tif (detail.lubricated) return true;\n\t\t\tstates.sample = detail;\n\t\t\tthis.#accumulate(states.fields, options.fields, detail);\n\t\t\treturn false;\n\t\t};\n\n\t#accumulate = (\n\t\tstateFields: PerEventStates['fields'],\n\t\toptionsFields: PerEventOption['fields'],\n\t\tdetail: GeneralObject,\n\t) => {\n\t\tObject.entries(stateFields).forEach(([key, value]) => {\n\t\t\tif (typeof detail[key] !== 'number') return;\n\t\t\tconst config = optionsFields[key].countType;\n\t\t\tif (config === 'sum') {\n\t\t\t\tvalue.catch += detail[key];\n\t\t\t} else if (config === 'product') value.catch *= detail[key];\n\t\t});\n\t};\n\n\t#perFrame = () => {\n\t\tconst states = this.#states;\n\t\tconst options = this.options.lubricator;\n\t\tif (!options) return;\n\t\tObject.entries(states).forEach(([event, perEventStates]) => {\n\t\t\t// per event scope\n\t\t\tconst detail = perEventStates.sample;\n\t\t\tdetail.lubricated = true;\n\t\t\tlet needEmit = false;\n\t\t\tfor (const [field, value] of Object.entries(perEventStates.fields)) {\n\t\t\t\t// per field scope\n\t\t\t\tif (value.catch === 1) continue;\n\t\t\t\tconst type = options[event].fields[field].countType;\n\n\t\t\t\tlet absDiff: number, diff: number;\n\t\t\t\tif (type === 'sum') {\n\t\t\t\t\tdiff = value.catch - value.release;\n\t\t\t\t\tabsDiff = Math.abs(diff);\n\t\t\t\t} else {\n\t\t\t\t\tdiff = value.catch / value.release;\n\t\t\t\t\tabsDiff = this.#reciprocalAbs(diff) - 1;\n\t\t\t\t}\n\n\t\t\t\tif (absDiff <= options[event].fields[field].diminishBoundary) {\n\t\t\t\t\tif (!needEmit) needEmit = true;\n\t\t\t\t\tdetail[field] = diff;\n\t\t\t\t\tvalue.release = 1;\n\t\t\t\t\tvalue.catch = 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// more to interpolate\n\t\t\t\tlet delta: number;\n\t\t\t\tif (type === 'sum') {\n\t\t\t\t\tdelta = diff * options[event].decayFactor;\n\t\t\t\t\tvalue.release += delta;\n\t\t\t\t} else {\n\t\t\t\t\tdelta = Math.pow(diff, options[event].decayFactor);\n\t\t\t\t\tvalue.release *= delta;\n\t\t\t\t}\n\t\t\t\tdetail[field] = delta;\n\t\t\t\tneedEmit = true;\n\t\t\t}\n\t\t\tif (needEmit) this.dispatch(event as keyof Events, detail as never);\n\t\t});\n\t\tthis.#animationId = requestAnimationFrame(this.#perFrame);\n\t};\n\n\t// in: positive number; out: positive number > 1\n\t#reciprocalAbs = (num: number) => (num > 1 ? num : 1 / num);\n\n\t// oxlint-disable-next-line typescript/no-explicit-any\n\tmodifiers: Record<string, any> = {};\n}\n\nexport const panPreset = {\n\tdecayFactor: 0.25,\n\tfields: {\n\t\tdeltaX: {\n\t\t\tcountType: 'sum',\n\t\t\tdiminishBoundary: 0.5,\n\t\t},\n\t\tdeltaY: {\n\t\t\tcountType: 'sum',\n\t\t\tdiminishBoundary: 0.5,\n\t\t},\n\t},\n} satisfies PerEventOption;\n\nexport const dragPreset = panPreset;\n\nexport const zoomPreset = {\n\tdecayFactor: 0.25,\n\tfields: {\n\t\tfactor: {\n\t\t\tcountType: 'product',\n\t\t\tdiminishBoundary: 0.01,\n\t\t},\n\t},\n} satisfies PerEventOption;\n","import type { BaseOptions, Pointer, Pointers } from '@/declarations';\n\nimport BaseModule from '@/baseModule';\nimport { getLast } from '@/utils';\n\ninterface Options extends BaseOptions {\n\tclickPreserveTime?: number;\n\tmoveThreshold?: number;\n}\n\nexport default class Click extends BaseModule<Options> {\n\t#lastClickTime = -Infinity;\n\t#clickSteak = 0;\n\n\tonPointerDown = (_e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tconst pointer0 = this.getNthPointer(0);\n\t\t\t/*\n interrupted means that when a pointer is moving on the screen while another pointer is down, possibly for zooming, both pointers will be seen as \"interrupted\" so that they won't be used for triggering a real click.\n */\n\t\t\tpointer0.interrupted = true;\n\t\t\tpointer.interrupted = true;\n\t\t}\n\t};\n\n\tonPointerUp = (e: PointerEvent, pointer: Pointer) => {\n\t\tif (pointer.interrupted) return;\n\t\tconst threshold = this.options.moveThreshold ?? 5;\n\t\tif (\n\t\t\tMath.abs(pointer.records[0].x - e.clientX) >= threshold ||\n\t\t\tMath.abs(pointer.records[0].y - e.clientY) >= threshold\n\t\t)\n\t\t\treturn;\n\t\tconst newLast = getLast(pointer.records).timestamp;\n\t\tconst time = this.options.clickPreserveTime ?? 400;\n\t\tif (newLast - this.#lastClickTime <= time) this.#clickSteak++;\n\t\telse this.#clickSteak = 1;\n\t\tthis.#lastClickTime = newLast;\n\t\tconst coords = this.toTargetCoords({ x: e.clientX, y: e.clientY });\n\t\tthis.dispatch('trueClick', {\n\t\t\t...coords,\n\t\t\ttarget: pointer.target,\n\t\t\tstreak: this.#clickSteak,\n\t\t});\n\t};\n}\n","import type { Pointer, Pointers } from '@/declarations';\n\nimport BaseModule from '@/baseModule';\nimport { getLast } from '@/utils';\n\nexport default class Drag extends BaseModule {\n\tonPointerMove = (e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tconst last = getLast(pointer.records, 1);\n\t\tif (pointers.size === 1) {\n\t\t\tconst dx = e.clientX - last.x;\n\t\t\tconst dy = e.clientY - last.y;\n\t\t\tthis.dispatch('drag', { deltaX: dx, deltaY: dy, x: e.clientX, y: e.clientY });\n\t\t}\n\t};\n}\n","import type { Coordinates, Pointer, Pointers } from '@/declarations';\n\nimport BaseModule from '@/baseModule';\nimport { getLast } from '@/utils';\n\nexport default class MultitouchPanZoom extends BaseModule {\n\t#pinchZoomState = {\n\t\tlastDistance: 0,\n\t\tlastMidpoint: { x: 0, y: 0 },\n\t};\n\n\t#getPointerDistance() {\n\t\tconst pointer0Coords = getLast(this.getNthPointer(0).records);\n\t\tconst pointer1Coords = getLast(this.getNthPointer(1).records);\n\t\tconst dx = pointer0Coords.x - pointer1Coords.x;\n\t\tconst dy = pointer0Coords.y - pointer1Coords.y;\n\t\treturn Math.sqrt(dx * dx + dy * dy);\n\t}\n\n\t// output screen coords\n\t#getPointerMidpoint() {\n\t\tconst pointer0Coords = getLast(this.getNthPointer(0).records);\n\t\tconst pointer1Coords = getLast(this.getNthPointer(1).records);\n\t\treturn {\n\t\t\tx: (pointer0Coords.x + pointer1Coords.x) / 2,\n\t\t\ty: (pointer0Coords.y + pointer1Coords.y) / 2,\n\t\t};\n\t}\n\n\tonPointerDown = (_e: PointerEvent, _pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tthis.#pinchZoomState.lastDistance = this.#getPointerDistance();\n\t\t\tthis.#pinchZoomState.lastMidpoint = this.toTargetCoords(this.#getPointerMidpoint());\n\t\t}\n\t};\n\n\tonPointerMove = (_e: PointerEvent, _pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tconst newDistance = this.#getPointerDistance();\n\t\t\tconst newMidpointOnScreen = this.#getPointerMidpoint();\n\t\t\tconst zoomFactor = newDistance / this.#pinchZoomState.lastDistance;\n\t\t\tthis.#pinchZoomState.lastDistance = newDistance;\n\t\t\tconst newMidpoint = this.toTargetCoords(newMidpointOnScreen);\n\t\t\tconst dx = newMidpoint.x - this.#pinchZoomState.lastMidpoint.x;\n\t\t\tconst dy = newMidpoint.y - this.#pinchZoomState.lastMidpoint.y;\n\t\t\tthis.#pinchZoomState.lastMidpoint = newMidpoint;\n\t\t\tthis.#dispatchPanEvent({ deltaX: dx, deltaY: dy });\n\t\t\tthis.#dispatchZoomEvent(zoomFactor, newMidpoint);\n\t\t}\n\t};\n\n\t#dispatchZoomEvent(factor: number, origin: Coordinates) {\n\t\tthis.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: { deltaX: number; deltaY: number }) {\n\t\tthis.dispatch('pan', diff);\n\t}\n}\n","import type BaseModule from '@/baseModule';\nimport type {\n\tAugmentation,\n\tCoordinates,\n\tEvents,\n\tGeneralObject,\n\tModuleCtor,\n\tModuleInput,\n\tModuleInputCtor,\n\tOptions,\n\tPointers,\n\tReloadable,\n} from '@/declarations';\n\nimport { HookKeys } from '@/baseModule';\nimport { toArray } from '@/utils';\n\nexport class Pointeract<T extends ModuleInputCtor = []> {\n\t#element: HTMLElement;\n\t#pointers: Pointers = new Map();\n\t#modules: Record<string, BaseModule> = {};\n\t#pausedModules: Record<string, BaseModule> = {};\n\t#_window: Window | null;\n\t#subscribers: { [K in keyof Events<T>]?: Set<(event: Events<T>[K]) => void> } = {};\n\toptions: Options<T>;\n\tdeclare private _augmentSlot: unknown;\n\n\tget #window() {\n\t\tif (!this.#_window) throw new Error('[Pointeract] Window is not defined.');\n\t\treturn this.#_window;\n\t}\n\n\tconstructor(options: Options<T>, _modules?: T) {\n\t\tconst modules = toArray(_modules ? _modules : ([] as Array<ModuleCtor>));\n\t\tthis.#_window = options.element.ownerDocument.defaultView;\n\t\tthis.#element = options.element;\n\t\tif (!options.coordinateOutput) options.coordinateOutput = 'relative';\n\t\tthis.options = options;\n\t\tmodules.forEach((module) => {\n\t\t\tconst instance = new module(\n\t\t\t\tthis.moduleUtils as PointeractInterface['moduleUtils'],\n\t\t\t\tthis.#window,\n\t\t\t\tthis.#pointers,\n\t\t\t\tthis.#element,\n\t\t\t\tthis.options,\n\t\t\t);\n\t\t\tObject.assign(instance, { options });\n\t\t\tthis.#modules[module.name] = instance;\n\t\t});\n\t}\n\n\ton = <K extends keyof Events<T>>(type: K, listener: (event: Events<T>[K]) => void) => {\n\t\tif (!this.#subscribers[type]) this.#subscribers[type] = new Set();\n\t\tthis.#subscribers[type]?.add(listener);\n\t\treturn this;\n\t};\n\toff<K extends keyof Events<T>>(type: K, listener: (event: Events<T>[K]) => void) {\n\t\tthis.#subscribers[type]?.delete(listener);\n\t\treturn this;\n\t}\n\n\tprivate moduleUtils = {\n\t\tgetNthPointer: (n: number) => {\n\t\t\tconst error = new Error('[Pointeract] Invalid pointer index.');\n\t\t\tif (n < 0 || n >= this.#pointers.size) throw error;\n\t\t\tlet i = 0;\n\t\t\tfor (const value of this.#pointers.values()) {\n\t\t\t\tif (i === n) return value;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tthrow error;\n\t\t},\n\n\t\t// Screen to Container\n\t\ttoTargetCoords: (raw: Coordinates) => {\n\t\t\tif (this.options.coordinateOutput === 'absolute') return raw;\n\t\t\tconst rect = this.#element.getBoundingClientRect();\n\t\t\traw.x -= rect.left;\n\t\t\traw.y -= rect.top;\n\t\t\tif (this.options.coordinateOutput === 'relative') return raw;\n\t\t\traw.x /= rect.width;\n\t\t\traw.y /= rect.height;\n\t\t\treturn raw;\n\t\t},\n\n\t\tdispatch: <N extends keyof Events<T>>(\n\t\t\t...args: undefined extends Events<T>[N] ? [N] : [N, Events<T>[N]]\n\t\t) => {\n\t\t\tconst name = args[0];\n\t\t\tconst e = args[1];\n\t\t\tlet lastResult: boolean | Events<T>[N] = true;\n\t\t\tfor (const value of Object.values(this.#modules)) {\n\t\t\t\tif (!value.modifiers || !(name in value.modifiers)) continue;\n\t\t\t\tlastResult =\n\t\t\t\t\te === undefined\n\t\t\t\t\t\t? (value.modifiers[name] as () => boolean)()\n\t\t\t\t\t\t: (\n\t\t\t\t\t\t\t\tvalue.modifiers[name] as (\n\t\t\t\t\t\t\t\t\tdetail?: Events<T>[N],\n\t\t\t\t\t\t\t\t) => boolean | Events<T>[N]\n\t\t\t\t\t\t\t)(e);\n\t\t\t\tif (lastResult === false) return;\n\t\t\t}\n\t\t\tlet event: Events<T>[N];\n\t\t\tif (lastResult === true) event = e as Events<T>[N];\n\t\t\telse event = lastResult;\n\t\t\tthis.#subscribers[name]?.forEach((listener) => listener(event));\n\t\t},\n\n\t\taugment: (aug: GeneralObject) => {\n\t\t\tObject.entries(aug).forEach(([key, value]) => (this[key as '_augmentSlot'] = value));\n\t\t},\n\t};\n\n\tdispatch = this.moduleUtils.dispatch;\n\n\t#runHooks<K extends HookKeys>(field: K, ...args: Parameters<Required<BaseModule>[K]>) {\n\t\tObject.values(this.#modules).forEach((module) => {\n\t\t\tconst hook = module[field];\n\t\t\t// oxlint-disable-next-line typescript/no-explicit-any\n\t\t\tif (hook) hook(...(args as any));\n\t\t});\n\t}\n\n\t#onPointerDown = (e: PointerEvent) => {\n\t\tif (this.#pointers.size >= 2) return;\n\t\tif (e.isPrimary) this.#pointers.clear();\n\t\tconst pointer = {\n\t\t\trecords: [{ x: e.clientX, y: e.clientY, timestamp: Date.now() }],\n\t\t\ttarget: e.target,\n\t\t};\n\t\tthis.#pointers.set(e.pointerId, pointer);\n\t\tthis.#runHooks('onPointerDown', e, pointer, this.#pointers);\n\t};\n\n\t#onPointerMove = (e: PointerEvent) => {\n\t\tconst pointer = this.#pointers.get(e.pointerId);\n\t\tif (!pointer) return;\n\t\tpointer.records.push({ x: e.clientX, y: e.clientY, timestamp: Date.now() });\n\t\tthis.#runHooks('onPointerMove', e, pointer, this.#pointers);\n\t};\n\n\t#onPointerUp = (e: PointerEvent) => {\n\t\tconst pointer = this.#pointers.get(e.pointerId);\n\t\tif (!pointer) return;\n\t\tthis.#pointers.delete(e.pointerId);\n\t\tthis.#runHooks('onPointerUp', e, pointer, this.#pointers);\n\t};\n\n\t#onWheel = (e: WheelEvent) => this.#runHooks('onWheel', e);\n\n\tstop = (_toStop?: Reloadable<T>) => {\n\t\tconst stopPointeract = () => {\n\t\t\tthis.#element.removeEventListener('pointerdown', this.#onPointerDown);\n\t\t\tthis.#window.removeEventListener('pointermove', this.#onPointerMove);\n\t\t\tthis.#window.removeEventListener('pointerup', this.#onPointerUp);\n\t\t\tthis.#element.removeEventListener('wheel', this.#onWheel);\n\t\t\tthis.#runHooks('onStop');\n\t\t};\n\t\tconst stopModule = (moduleCtor: ModuleCtor) => {\n\t\t\tif (!(moduleCtor.name in this.#modules)) return;\n\t\t\tconst module = this.#modules[moduleCtor.name];\n\t\t\tif (module.onStop) module.onStop();\n\t\t\tthis.#pausedModules[moduleCtor.name] = module;\n\t\t\tdelete this.#modules[moduleCtor.name];\n\t\t};\n\t\tif (!_toStop) stopPointeract();\n\t\telse\n\t\t\ttoArray(_toStop).forEach((module) => {\n\t\t\t\tstopModule(module);\n\t\t\t});\n\t\treturn this;\n\t};\n\n\tstart = (_toStart?: Reloadable<T>) => {\n\t\tconst startPointeract = () => {\n\t\t\tthis.#element.addEventListener('pointerdown', this.#onPointerDown);\n\t\t\tthis.#window.addEventListener('pointermove', this.#onPointerMove);\n\t\t\tthis.#window.addEventListener('pointerup', this.#onPointerUp);\n\t\t\tthis.#element.addEventListener('wheel', this.#onWheel, { passive: false });\n\t\t\tthis.#runHooks('onStart');\n\t\t};\n\t\tconst startModule = (moduleCtor: ModuleCtor) => {\n\t\t\tif (!(moduleCtor.name in this.#pausedModules)) return;\n\t\t\tconst module = this.#pausedModules[moduleCtor.name];\n\t\t\tif (module.onStart) module.onStart();\n\t\t\tthis.#modules[moduleCtor.name] = module;\n\t\t\tdelete this.#pausedModules[moduleCtor.name];\n\t\t};\n\t\tif (!_toStart) startPointeract();\n\t\telse\n\t\t\ttoArray(_toStart).forEach((module) => {\n\t\t\t\tstartModule(module);\n\t\t\t});\n\t\treturn this;\n\t};\n\n\tdispose = () => {\n\t\tthis.stop();\n\t\tthis.#_window = null;\n\t\tthis.#runHooks('dispose');\n\t\tthis.#subscribers = {};\n\t};\n}\n\ntype PointeractType = new <M extends ModuleInputCtor = []>(\n\t...args: ConstructorParameters<typeof Pointeract<M>>\n) => Pointeract<M> & Augmentation<M>;\n\nexport type PointeractInterface<M extends ModuleInput = []> = Pointeract<never> & Augmentation<M>;\n\nexport default Pointeract as PointeractType;\n","import BaseModule from '@/baseModule';\n\nexport default class PreventDefault extends BaseModule {\n\tonWheel = (e: WheelEvent) => e.preventDefault();\n\t#preventDefaultFunction = (e: Event) => e.preventDefault();\n\n\tonStart = () => {\n\t\tthis.element.style.touchAction = 'none';\n\t\tthis.element.addEventListener('gesturestart', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t\tthis.element.addEventListener('gesturechange', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t};\n\n\tonStop = () => {\n\t\tthis.element.style.touchAction = '';\n\t\tthis.element.removeEventListener('gesturestart', this.#preventDefaultFunction);\n\t\tthis.element.removeEventListener('gesturechange', this.#preventDefaultFunction);\n\t};\n\n\tdispose = this.onStop;\n}\n","import type { Coordinates, BaseOptions } from '@/declarations';\n\nimport BaseModule, { BaseArgs } from '@/baseModule';\nimport { fillIn } from '@/utils';\n\n/*\nto normal computer users:\n\n# normal schema\ndiff y > 0 => zooms in => zoom factor < 1\ndiff y < 0 => zooms out => zoom factor > 1\n\n# professional schema\ndiff y > 0 => pan up => pan y < 0\ndiff y < 0 => pan down => pan y > 0\ndiff x > 0 => pan left => pan x < 0\ndiff y < 0 => pan right => pan y > 0\n*/\n\ninterface Options extends BaseOptions {\n\tproControlSchema?: boolean;\n\tzoomFactor?: number;\n\tlockControlSchema?: boolean;\n}\n\nexport default class wheelPanZoom extends BaseModule<Options> {\n\tconstructor(...args: BaseArgs) {\n\t\tsuper(...args);\n\t\tfillIn(\n\t\t\t{ proControlSchema: false, zoomFactor: 0.1, lockControlSchema: false },\n\t\t\tthis.options,\n\t\t);\n\t}\n\n\tonWheel = (e: WheelEvent) => {\n\t\tconst options = this.options as Required<Options>;\n\t\tif (\n\t\t\t!options.proControlSchema &&\n\t\t\t!options.lockControlSchema &&\n\t\t\t(e.ctrlKey || e.shiftKey || Math.abs(e.deltaX) > Math.abs(e.deltaY))\n\t\t)\n\t\t\toptions.proControlSchema = true;\n\t\tif (options.proControlSchema) {\n\t\t\tif (e.ctrlKey) {\n\t\t\t\tconst scaleFactor = 1 - options.zoomFactor * e.deltaY;\n\t\t\t\tconst origin = this.toTargetCoords({ x: e.clientX, y: e.clientY });\n\t\t\t\tthis.#dispatchZoomEvent(scaleFactor, origin);\n\t\t\t} else if (e.shiftKey && Math.abs(e.deltaX) <= Math.abs(e.deltaY))\n\t\t\t\tthis.#dispatchPanEvent({ deltaX: -e.deltaY, deltaY: -e.deltaX });\n\t\t\telse this.#dispatchPanEvent({ deltaX: -e.deltaX, deltaY: -e.deltaY });\n\t\t} else {\n\t\t\tconst scaleFactor = 1 - (options.zoomFactor / 20) * e.deltaY;\n\t\t\tconst origin = this.toTargetCoords({ x: e.clientX, y: e.clientY });\n\t\t\tthis.#dispatchZoomEvent(scaleFactor, origin);\n\t\t}\n\t};\n\n\t#dispatchZoomEvent(factor: number, origin: Coordinates) {\n\t\tthis.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: { deltaX: number; deltaY: number }) {\n\t\tthis.dispatch('pan', diff);\n\t}\n}\n"],"names":["BaseModule","constructor","utils","window","pointers","element","options","this","getNthPointer","toTargetCoords","augment","dispatch","onPointerDown","onPointerUp","onPointerMove","onWheel","onStart","onStop","dispose","modifiers","getLast","arr","num","length","toArray","toTrans","Array","isArray","panPreset","decayFactor","fields","deltaX","countType","diminishBoundary","deltaY","dragPreset","lastClickTime","Infinity","clickSteak","_e","pointer","size","interrupted","e","threshold","moveThreshold","Math","abs","records","x","clientX","y","clientY","newLast","timestamp","time","clickPreserveTime","coords","target","streak","last","dx","dy","states","animationId","args","super","lubricatee","lubricator","Object","entries","forEach","key","value","sample","keys","field","catch","release","makeLubricate","requestAnimationFrame","perFrame","cancelAnimationFrame","values","detail","lubricated","accumulate","stateFields","optionsFields","config","event","perEventStates","needEmit","type","absDiff","diff","delta","reciprocalAbs","pow","pinchZoomState","lastDistance","lastMidpoint","getPointerDistance","pointer0Coords","pointer1Coords","sqrt","getPointerMidpoint","_pointer","newDistance","newMidpointOnScreen","zoomFactor","newMidpoint","dispatchPanEvent","dispatchZoomEvent","factor","origin","Map","modules","pausedModules","_window","subscribers","Error","_modules","ownerDocument","defaultView","coordinateOutput","module","instance","moduleUtils","assign","name","on","listener","Set","add","off","delete","n","error","i","raw","rect","getBoundingClientRect","left","top","width","height","lastResult","aug","runHooks","hook","isPrimary","clear","Date","now","set","pointerId","get","push","stop","_toStop","stopModule","moduleCtor","removeEventListener","stopPointeract","start","_toStart","startModule","addEventListener","passive","startPointeract","preventDefault","preventDefaultFunction","style","touchAction","patch","k","v","fillIn","proControlSchema","lockControlSchema","ctrlKey","shiftKey","scaleFactor"],"mappings":"gFA2BA,MAAqBA,EAepB,WAAAC,CACCC,EACUC,EACAC,EACAC,EACVC,GA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"}
@@ -1,62 +0,0 @@
1
- import type BaseModule from './baseModule';
2
- export type GeneralArguments = Array<any>;
3
- export type GeneralObject = Record<Indexable, any>;
4
- export type Indexable = string | number | symbol;
5
- type KnownKeys<T> = keyof {
6
- [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
7
- };
8
- export type Constrain<T> = Pick<T, KnownKeys<T>>;
9
- type WrapInArray<T> = T extends Array<infer U> ? Array<U> : [T];
10
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
11
- type Instances<T extends ProcessedModuleInput> = T extends Array<ModuleCtor> ? InstanceType<T[number]> : T[number];
12
- type Orchestratable<T extends ModuleInput, K extends 'options' | '_Events' | '_Augmentation'> = UnionToIntersection<AllModuleInstances<T>[K]>;
13
- type ModuleInstance = BaseModule<any, any, any>;
14
- export type ModuleCtor = typeof BaseModule<any, any, any>;
15
- export type ModuleInput = ModuleCtor | ModuleInstance | Array<ModuleInstance> | Array<ModuleCtor>;
16
- export type ModuleInputCtor = ModuleCtor | Array<ModuleCtor>;
17
- type ProcessedModuleInput = Array<ModuleInstance> | Array<ModuleCtor>;
18
- type AllModuleInstances<T extends ModuleInput> = Instances<WrapInArray<T>>;
19
- export type Options<T extends ModuleInput = []> = Orchestratable<T, 'options'> & BaseOptions;
20
- export type Events<T extends ModuleInput = []> = Constrain<Orchestratable<T, '_Events'> & StdEvents>;
21
- export type Augmentation<T extends ModuleInput = []> = Orchestratable<T, '_Augmentation'>;
22
- type ReloadableAtom<T extends ModuleInputCtor> = WrapInArray<T>[number];
23
- export type Reloadable<T extends ModuleInputCtor> = ReloadableAtom<T> | Array<ReloadableAtom<T>>;
24
- export type Coordinates = {
25
- x: number;
26
- y: number;
27
- };
28
- export type Pointers = Map<number, Pointer>;
29
- export type Pointer = {
30
- records: Array<{
31
- x: number;
32
- y: number;
33
- timestamp: number;
34
- }>;
35
- target: EventTarget | null;
36
- [key: Indexable]: any;
37
- };
38
- export interface StdEvents {
39
- pan: {
40
- deltaX: number;
41
- deltaY: number;
42
- };
43
- drag: {
44
- deltaX: number;
45
- deltaY: number;
46
- x: number;
47
- y: number;
48
- };
49
- trueClick: Coordinates & {
50
- target: EventTarget | null;
51
- streak: number;
52
- };
53
- zoom: Coordinates & {
54
- factor: number;
55
- };
56
- [key: string]: unknown;
57
- }
58
- export interface BaseOptions {
59
- coordinateOutput?: 'absolute' | 'relative' | 'relativeFraction';
60
- element: HTMLElement;
61
- }
62
- export {};