pointeract 1.0.1 → 1.1.1

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
@@ -1,15 +1,15 @@
1
1
  <h1 align="center">
2
2
  <a href="https://pointeract.consensia.cc">
3
- <img src="./assets/logoText.svg" alt="Pointeract" width="280px">
3
+ <img src="./assets/logo-text.svg" alt="Pointeract" width="280px">
4
4
  </a>
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"> modern, lightweight, robust and extensible user gesture recognizer </h4>
9
9
 
10
10
  <p align="center">
11
11
  <a href="https://github.com/hesprs/pointeract/actions">
12
- <img src="https://img.shields.io/github/actions/workflow/status/hesprs/pointeract/ci-main.yml?style=flat&logo=github&logoColor=white&label=CI&labelColor=d4ab00&color=333333" alt="CI Status" />
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
13
  </a>
14
14
  <a href="https://codecov.io/github/hesprs/pointeract">
15
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" />
@@ -18,7 +18,7 @@
18
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
19
  </a>
20
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="Code Quality" />
21
+ <img src="https://img.shields.io/badge/Documentation-Ready-333333?labelColor=5C73E7&logo=vitepress&logoColor=white" alt="Documentation" />
22
22
  </a>
23
23
  <a href="https://www.npmjs.com/package/pointeract">
24
24
  <img src="https://img.shields.io/npm/v/pointeract?logo=npm&labelColor=red&logoColor=white&color=333333" alt="npm package" />
@@ -27,34 +27,34 @@
27
27
  <img src="https://img.shields.io/badge/Snyk%20Security-Monitored-333333?logo=snyk&style=flat&labelColor=8A2BE2&logoColor=white" alt="library security" />
28
28
  </a>
29
29
  <a href="https://bundlephobia.com/package/pointeract">
30
- <img src="https://img.shields.io/bundlephobia/minzip/pointeract?style=flat&logo=webpack&labelColor=orange&logoColor=white&color=333333&label=Minified+Gzipped%20Size" alt="package size" />
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
31
  </a>
32
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-Human-333333?labelColor=25C260" alt="Made by Human" />
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" />
34
34
  </p>
35
35
 
36
36
  <p align="center">
37
- <a href="#whats-pointeract">Introduction</a> •
38
- <a href="#advantages">Advantages</a>
39
- <a href="#get-started">Get Started</a> •
40
- <a href="#currently-supported-interactions">Features</a> •
41
- <a href="#how-pointeract-stands-out">Comparison</a>
42
- <a href="#get-involved">Get Involved</a> •
43
- <a href="#license">License</a>
37
+ <a href="https://pointeract.consensia.cc/playground">
38
+ <strong>Demo</strong>
39
+ </a> •
40
+ <a href="https://pointeract.consensia.cc">
41
+ <strong>Documentation</strong>
42
+ </a> •
43
+ <a href="https://www.npmjs.com/package/pointeract">
44
+ <strong>npm</strong>
45
+ </a>
44
46
  </p>
45
47
 
46
48
  ## What's Pointeract?
47
49
 
48
- Pointeract is a tiny utility library focusing on one thing - handling user interactions with DOM elements. It is fully typed, small, and easy to use. You need to bind your DOM elements, load some modules, and it will start monitoring user interactions and dispatch events like `trueClick` and `pan` with data.
50
+ Pointeract is a tiny JavaScript/TypeScript utility library focusing on one thing - handling user interactions with DOM elements, e.g. multitouch and touchpad.
49
51
 
50
- It is built in an extensible architecture with base bundle size 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.
51
-
52
- Access our documentation [here](https://pointeract.consensia.cc/).
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.
53
53
 
54
54
  ## Advantages
55
55
 
56
56
  - **🐣 Tiny**: With base **1KB** minified and gzipped, **1-2KB** for normal usage.
57
- - **💪 Robust**: Excels at complex gestures where most interaction libraries fail, [Why?](https://pointeract.consensia.cc/development/testing#chaotic-testing)
57
+ - **💪 Robust**: Excels at complex gestures where most interaction libraries fail, [Why?](https://pointeract.consensia.cc/development/testing#monkey-test)
58
58
  - **🧩 Extensible**: Extend Pointeract effortlessly via our module API.
59
59
  - **🔌 Flexible during Runtime**: Options are updated reactively. Stop/start any module during runtime.
60
60
  - **🛡️ Safe**: Not modifying the DOM (except the `PreventDefault` module). Meticulous clean up prevents memory leaks.
@@ -72,33 +72,40 @@ $ pnpm add pointeract
72
72
 
73
73
  # yarn
74
74
  $ yarn add pointeract
75
-
76
- # bun
77
- $ bun add pointeract
78
75
  ```
79
76
 
80
77
  Or include the following lines directly in your HTML file:
81
78
 
82
79
  ```html
83
80
  <script type="module">
84
- import { Pointeract } from 'https://unpkg.com/pointeract/dist/index.js';
81
+ import { Pointeract } from 'https://unpkg.com/pointeract';
85
82
  </script>
86
83
  ```
87
84
 
88
- This link ships the latest ESM version by default, to access CJS version or earlier versions, try using a different URL like:
85
+ This link ships the latest ESM version by default.
89
86
 
90
- ```html
91
- <script src="https://unpkg.com/pointeract@1.0.0/dist/index.cjs"></script>
87
+ Then simply grab the core class and a module:
88
+
89
+ ```TypeScript
90
+ import { Pointeract, Drag } from 'pointeract';
91
+
92
+ new Pointeract({ element: yourElement }, Drag)
93
+ .start()
94
+ .on('drag', e => console.log(e));
92
95
  ```
93
96
 
94
- The link above ships version 1.0.0 in CJS.
97
+ Congratulations! You can now press your mouse or finger to the element and move, the console will log events like a waterfall.
98
+
99
+ **Read next**: dive into the usage of Pointeract in [Use Pointeract](https://pointeract.consensia.cc/basic/use-pointeract).
95
100
 
96
- ## Currently Supported Interactions
101
+ ## Currently Supported Features
97
102
 
98
103
  - **Click (Double Click, Triple Click, Quadruple Click, Any Click)**
99
104
  - **Drag**
100
105
  - **Pan and Zoom via Mouse Wheel (`ctrl`/`shift` key binding, touchpad support)**
101
106
  - **Pan and Zoom via Multitouch (Pan, Pinch)**
107
+ - **One-line Prevent Default**
108
+ - **Smooth Everything (drag / pan / zoom / any interaction involving numbers)**
102
109
 
103
110
  Those interactions are shipped via modules, which can be composed from a single drag-and-drop to a canvas app.
104
111
 
@@ -108,15 +115,15 @@ Missing your desired interaction? [Write your own module](https://pointeract.con
108
115
 
109
116
  There're already plenty of interaction libraries out there, most famous ones are `Interact.js` and `Hammer.js`, but Pointeract is different.
110
117
 
111
- | Criteria | Pointeract | [Hammer.js](https://hammerjs.github.io) | [Interact.js](https://interactjs.io) |
112
- |:---------------------------------------------------------------------------------------------|:-----------------------------------------------------:|:------------------------------------------------:|:---------------------------------------------------:|
113
- | Written in TypeScript? | | | |
114
- | Tree-shakeable? | [✅](https://bundlephobia.com/package/pointeract) | [❌](https://bundlephobia.com/package/hammerjs) | [❌](https://bundlephobia.com/package/interactjs) |
115
- | Bundle Size (Minified + Gzipped) | 👑 [2KB](https://bundlephobia.com/package/pointeract) | [7KB](https://bundlephobia.com/package/hammerjs) | [28KB](https://bundlephobia.com/package/interactjs) |
116
- | Last Updated | 👑 Actively Maintained | 2015 | 2023 |
117
- | Features | Pointer and Wheel Related | Pointer Related | 👑 Pointer and Wheel Related + Comprehensive Utils |
118
- | Robust? (See [Testing](https://pointeract.consensia.cc/development/testing#chaotic-testing)) | | ❌ Element Jerks | ❌ Element Ignores the Second Touch |
119
- | Extensible? | | | |
118
+ | Criteria | Pointeract | [Hammer.js](https://hammerjs.github.io) | [Interact.js](https://interactjs.io) |
119
+ | :-------------------------------------------------------- | :---------------------------------------------------: | :----------------------------------------------: | :-------------------------------------------------: |
120
+ | Written in TypeScript? | | | |
121
+ | Tree-shakeable? | [✅](https://bundlephobia.com/package/pointeract) | [❌](https://bundlephobia.com/package/hammerjs) | [❌](https://bundlephobia.com/package/interactjs) |
122
+ | Total Bundle Size (Minified + Gzipped) | 👑 [3KB](https://bundlephobia.com/package/pointeract) | [7KB](https://bundlephobia.com/package/hammerjs) | [28KB](https://bundlephobia.com/package/interactjs) |
123
+ | Last Updated | 👑 Actively Maintained | 2015 | 2023 |
124
+ | Features | Pointer and Wheel Related + Some Utils | Pointer Related | 👑 Pointer and Wheel Related + Comprehensive Utils |
125
+ | Robust? (See [Testing](/development/testing#monkey-test)) | | ❌ Element Jerks | ❌ Element Ignores the Second Touch |
126
+ | Extensible? | | | |
120
127
 
121
128
  ## Get Involved
122
129
 
@@ -127,6 +134,6 @@ This project welcomes anyone that have ideas to improve it.
127
134
  - [Start a new thread in Discussions](https://github.com/hesprs/pointeract/discussions/new) if you have feature requests or questions, please avoid posting them in Issues.
128
135
  - [Report a vulnerability](https://github.com/hesprs/pointeract/security/advisories/new) if you find one, please do not disclose it publicly.
129
136
 
130
- ## License
137
+ ## Copyright and License
131
138
 
132
- Pointeract is licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html).
139
+ Copyright ©️ 2025-2026 Hesprs (Hēsperus) | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
@@ -0,0 +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};
2
+ //# sourceMappingURL=index.js.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js.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","moduleCtor","stopPointeract","start","_toStart","startModule","startPointeract"],"mappings":"AA2BA,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,QACrBH,KAAKI,SAAWT,EAAMS,SACtBJ,KAAKD,QAAUA,CAChB,CAnBUE,cACAC,eACAC,QACAC,SAGVL,QAeAM,cACAC,YACAC,cACAC,QACAC,QACAC,OACAC,QACAC,UC7DM,SAASC,EAAWC,E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I,EAAS6C,EAAWhC,OAOjC,OALK8B,EAEJhK,EAAQgK,GAAS/E,QAAS6C,IACzBmC,EAAWnC,KAjBU,MACtB/I,MAAKF,EAASgF,oBAAoB,cAAe9E,MAAKK,GACtDL,MAAKJ,EAAQkF,oBAAoB,cAAe9E,MAAKO,GACrDP,MAAKJ,EAAQkF,oBAAoB,YAAa9E,MAAKM,GACnDN,MAAKF,EAASgF,oBAAoB,QAAS9E,MAAKQ,GAChDR,MAAKsK,EAAU,WASFc,GAKPpL,MAGRqL,MAASC,IACR,MAOMC,EAAeJ,IACpB,KAAMA,EAAWhC,QAAQnJ,MAAKuI,GAAiB,OAC/C,MAAMQ,EAAS/I,MAAKuI,EAAe4C,EAAWhC,MAC1CJ,EAAOtI,SAASsI,EAAOtI,UAC3BT,MAAKsI,EAAS6C,EAAWhC,MAAQJ,SAC1B/I,MAAKuI,EAAe4C,EAAWhC,OAOvC,OALKmC,EAEJrK,EAAQqK,GAAUpF,QAAS6C,IAC1BwC,EAAYxC,KAjBU,MACvB/I,MAAKF,EAAS8E,iBAAiB,cAAe5E,MAAKK,GACnDL,MAAKJ,EAAQgF,iBAAiB,cAAe5E,MAAKO,GAClDP,MAAKJ,EAAQgF,iBAAiB,YAAa5E,MAAKM,GAChDN,MAAKF,EAAS8E,iBAAiB,QAAS5E,MAAKQ,EAAU,CAAEqE,SAAS,IAClE7E,MAAKsK,EAAU,YASDkB,GAKRxL,MAGRW,QAAU,KACTX,KAAKgL,OACLhL,MAAKwI,EAAW,KAChBxI,MAAKsK,EAAU,WACftK,MAAKyI,EAAe,CAAA"}
@@ -1,23 +1,34 @@
1
- import type { Constrain, GeneralObject, ModifierReturn, Pointer, Pointers, StdEvents } from './declarations';
2
- import type Pointeract from './pointeract';
3
- type IsAny<T> = 0 extends 1 & T ? true : false;
4
- export default class BaseModule<Events extends StdEvents = StdEvents> {
5
- protected utils: Omit<Pointeract<never>['moduleUtils'], 'dispatch'> & {
6
- dispatch: <T extends keyof Constrain<Events>>(name: T, ...args: IsAny<Events[T]['detail']> extends false ? [detail: Events[T]['detail']] : []) => void;
7
- };
1
+ import type { BaseOptions, GeneralObject, Pointer, Pointers, StdEvents, Constrain } from './declarations';
2
+ import type { Pointeract, PointeractInterface } from './pointeract';
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
+ ];
11
+ export default class BaseModule<O extends BaseOptions = BaseOptions, E extends StdEvents = StdEvents, A extends {} = {}> {
8
12
  protected window: Window;
9
13
  protected pointers: Pointers;
10
- protected monitoringElement: HTMLElement;
11
- constructor(utils: Pointeract<never>['moduleUtils'], window: Window, pointers: Pointers, monitoringElement: HTMLElement);
12
- readonly events: Events;
13
- options?: GeneralObject;
14
- dispose?: (...args: []) => void;
15
- modifier?: (...args: [string, unknown]) => ModifierReturn;
16
- onPointerDown?: (...args: [PointerEvent, Pointer, Pointers]) => void;
17
- onPointerMove?: (...args: [PointerEvent, Pointer, Pointers]) => void;
18
- onPointerUp?: (...args: [PointerEvent, Pointer, Pointers]) => void;
19
- onWheel?: (...args: [WheelEvent]) => void;
20
- onStart?: (...args: []) => void;
21
- onStop?: (...args: []) => void;
14
+ protected element: HTMLElement;
15
+ private static readonly _BaseModuleBrand;
16
+ readonly _Events: E;
17
+ readonly _Augmentation: A;
18
+ protected getNthPointer: Pointeract<[]>['moduleUtils']['getNthPointer'];
19
+ protected toTargetCoords: Pointeract<[]>['moduleUtils']['toTargetCoords'];
20
+ protected augment: (augmentation: A) => void;
21
+ protected dispatch: <K extends keyof Constrain<E>>(...arg: undefined extends E[K] ? [K] : [K, E[K]]) => void;
22
+ options: O;
23
+ constructor(utils: PointeractInterface['moduleUtils'], window: Window, pointers: Pointers, element: HTMLElement, options: GeneralObject);
24
+ onPointerDown?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;
25
+ onPointerUp?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;
26
+ onPointerMove?: (...args: [event: PointerEvent, pointer: Pointer, pointers: Pointers]) => void;
27
+ onWheel?: (...args: [event: WheelEvent]) => void;
28
+ onStart?: () => void;
29
+ onStop?: () => void;
30
+ dispose?: () => void;
31
+ modifiers?: {
32
+ [K in keyof Constrain<E>]?: (event: E[K]) => boolean | E[K];
33
+ };
22
34
  }
23
- export {};
@@ -2,27 +2,25 @@ import type BaseModule from './baseModule';
2
2
  export type GeneralArguments = Array<any>;
3
3
  export type GeneralObject = Record<Indexable, any>;
4
4
  export type Indexable = string | number | symbol;
5
- type Empty = {};
6
5
  type KnownKeys<T> = keyof {
7
6
  [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
8
7
  };
9
8
  export type Constrain<T> = Pick<T, KnownKeys<T>>;
10
- type UndefinedToObject<T> = T extends undefined ? Empty : GeneralObject extends T ? Empty : T;
11
9
  type WrapInArray<T> = T extends Array<infer U> ? Array<U> : [T];
12
10
  type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
13
- export type Ctors<T extends Array<BaseModule> | BaseModule> = T extends Array<BaseModule> ? {
14
- [K in keyof T]: new (...args: GeneralArguments) => T[K];
15
- } : [new (...args: GeneralArguments) => T];
16
- export type ModuleCtor = typeof BaseModule<StdEvents>;
17
- export type ModuleInput = ModuleCtor | Array<ModuleCtor>;
18
- type AllModuleInstances<T extends ModuleInput> = InstanceType<WrapInArray<T>[number]>;
19
- export type Options<T extends ModuleInput> = Partial<UnionToIntersection<UndefinedToObject<AllModuleInstances<T>['options']>> & BaseOptions>;
20
- export type EventMap<T extends ModuleInput> = Constrain<UnionToIntersection<AllModuleInstances<T>['events']>>;
21
- export type Reloadable<T extends ModuleInput> = WrapInArray<T>[number];
22
- export type ModifierReturn = true | false | {
23
- name: string;
24
- detail: unknown;
25
- };
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>>;
26
24
  export type Coordinates = {
27
25
  x: number;
28
26
  y: number;
@@ -37,23 +35,28 @@ export type Pointer = {
37
35
  target: EventTarget | null;
38
36
  [key: Indexable]: any;
39
37
  };
40
- export type Hooks = 'onPointerDown' | 'onPointerUp' | 'onPointerMove' | 'onWheel' | 'onStart' | 'onStop' | 'dispose' | 'modifier';
41
38
  export interface StdEvents {
42
- pan: CustomEvent<Coordinates>;
43
- drag: CustomEvent<Coordinates & {
44
- clientX: number;
45
- clientY: number;
46
- }>;
47
- trueClick: CustomEvent<Coordinates & {
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 & {
48
50
  target: EventTarget | null;
49
51
  streak: number;
50
- }>;
51
- zoom: CustomEvent<Coordinates & {
52
+ };
53
+ zoom: Coordinates & {
52
54
  factor: number;
53
- }>;
54
- [key: string]: CustomEvent;
55
+ };
56
+ [key: string]: unknown;
57
+ }
58
+ export interface BaseOptions {
59
+ coordinateOutput?: 'absolute' | 'relative' | 'relativeFraction';
60
+ element: HTMLElement;
55
61
  }
56
- type BaseOptions = {
57
- coordinateOutput: 'absolute' | 'relative' | 'relativeFraction';
58
- };
59
62
  export {};
@@ -1,8 +1,9 @@
1
- export { default as BaseModule } from './baseModule';
2
- export type { Coordinates, Ctors, Options, Pointer, Pointers, StdEvents } from './declarations';
1
+ export { default as BaseModule, type BaseArgs } from './baseModule';
2
+ export type { Options, Events, Pointer, Pointers, StdEvents, BaseOptions } from './declarations';
3
3
  export { default as Click } from './modules/click';
4
4
  export { default as Drag } from './modules/drag';
5
5
  export { default as MultitouchPanZoom } from './modules/multitouchPanZoom';
6
6
  export { default as PreventDefault } from './modules/preventDefault';
7
7
  export { default as WheelPanZoom } from './modules/wheelPanZoom';
8
- export { default as Pointeract } from './pointeract';
8
+ export { default as Lubricator, panPreset, dragPreset, zoomPreset } from './modules/lubricator';
9
+ export { default as Pointeract, type PointeractInterface } from './pointeract';
@@ -1,11 +1,12 @@
1
+ import type { BaseOptions, Pointer, Pointers } from '../declarations';
1
2
  import BaseModule from '../baseModule';
2
- import type { Pointer, Pointers } from '../declarations';
3
- export default class Click extends BaseModule {
3
+ interface Options extends BaseOptions {
4
+ clickPreserveTime?: number;
5
+ moveThreshold?: number;
6
+ }
7
+ export default class Click extends BaseModule<Options> {
4
8
  #private;
5
- options: {
6
- clickPreserveTime: number;
7
- moveThreshold: number;
8
- };
9
9
  onPointerDown: (_e: PointerEvent, pointer: Pointer, pointers: Pointers) => void;
10
10
  onPointerUp: (e: PointerEvent, pointer: Pointer) => void;
11
11
  }
12
+ export {};
@@ -1,5 +1,5 @@
1
- import BaseModule from '../baseModule';
2
1
  import type { Pointer, Pointers } from '../declarations';
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
  }
@@ -0,0 +1,55 @@
1
+ import BaseModule, { BaseArgs } from '../baseModule';
2
+ import { BaseOptions } from '../declarations';
3
+ interface Options extends BaseOptions {
4
+ lubricator?: Record<string, PerEventOption>;
5
+ }
6
+ type PerEventOption = {
7
+ decayFactor: number;
8
+ fields: Record<string, {
9
+ countType: 'sum' | 'product';
10
+ diminishBoundary: number;
11
+ }>;
12
+ };
13
+ export default class Lubricator extends BaseModule<Options> {
14
+ #private;
15
+ constructor(...args: BaseArgs);
16
+ onStart: () => void;
17
+ onStop: () => void;
18
+ modifiers: Record<string, any>;
19
+ }
20
+ export declare const panPreset: {
21
+ decayFactor: number;
22
+ fields: {
23
+ deltaX: {
24
+ countType: "sum";
25
+ diminishBoundary: number;
26
+ };
27
+ deltaY: {
28
+ countType: "sum";
29
+ diminishBoundary: number;
30
+ };
31
+ };
32
+ };
33
+ export declare const dragPreset: {
34
+ decayFactor: number;
35
+ fields: {
36
+ deltaX: {
37
+ countType: "sum";
38
+ diminishBoundary: number;
39
+ };
40
+ deltaY: {
41
+ countType: "sum";
42
+ diminishBoundary: number;
43
+ };
44
+ };
45
+ };
46
+ export declare const zoomPreset: {
47
+ decayFactor: number;
48
+ fields: {
49
+ factor: {
50
+ countType: "product";
51
+ diminishBoundary: number;
52
+ };
53
+ };
54
+ };
55
+ export {};
@@ -1,5 +1,5 @@
1
- import BaseModule from '../baseModule';
2
1
  import type { Pointer, Pointers } from '../declarations';
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,10 +1,13 @@
1
- import BaseModule from '../baseModule';
2
- export default class wheelPanZoom extends BaseModule {
1
+ import type { BaseOptions } from '../declarations';
2
+ import BaseModule, { BaseArgs } from '../baseModule';
3
+ interface Options extends BaseOptions {
4
+ proControlSchema?: boolean;
5
+ zoomFactor?: number;
6
+ lockControlSchema?: boolean;
7
+ }
8
+ export default class wheelPanZoom extends BaseModule<Options> {
3
9
  #private;
4
- options: {
5
- proControlSchema: boolean;
6
- zoomFactor: number;
7
- lockControlSchema: boolean;
8
- };
10
+ constructor(...args: BaseArgs);
9
11
  onWheel: (e: WheelEvent) => void;
10
12
  }
13
+ export {};
@@ -1,18 +1,18 @@
1
- import type { Coordinates, EventMap, GeneralObject, ModuleInput, Options, Reloadable } from './declarations';
2
- export default class Pointeract<T extends ModuleInput = []> extends EventTarget {
1
+ import type { Augmentation, Events, ModuleInput, ModuleInputCtor, Options, Reloadable } from './declarations';
2
+ export declare class Pointeract<T extends ModuleInputCtor = []> {
3
3
  #private;
4
- options: GeneralObject;
5
- constructor(monitoringElement: HTMLElement, _modules?: T, options?: Options<T>);
6
- on: <K extends keyof EventMap<T>>(type: K, listener: (event: EventMap<T>[K]) => void) => () => void;
7
- off<K extends keyof EventMap<T>>(type: K, listener: (event: EventMap<T>[K]) => void): void;
8
- readonly events: EventMap<T>;
9
- moduleUtils: {
10
- getNthValue: (n: number) => import("./declarations").Pointer;
11
- screenToTarget: (raw: Coordinates) => Coordinates;
12
- dispatch: <T_1>(name: string, detail?: T_1) => void;
13
- getLast: <T_1>(arr: Array<T_1>, num?: number) => T_1;
14
- };
4
+ options: Options<T>;
5
+ private _augmentSlot;
6
+ constructor(options: Options<T>, _modules?: T);
7
+ on: <K extends keyof Events<T>>(type: K, listener: (event: Events<T>[K]) => void) => this;
8
+ off<K extends keyof Events<T>>(type: K, listener: (event: Events<T>[K]) => void): this;
9
+ private moduleUtils;
10
+ dispatch: <N extends keyof Events<T>>(...args: undefined extends Events<T>[N] ? [N] : [N, Events<T>[N]]) => void;
15
11
  stop: (_toStop?: Reloadable<T>) => this;
16
12
  start: (_toStart?: Reloadable<T>) => this;
17
13
  dispose: () => void;
18
14
  }
15
+ type PointeractType = new <M extends ModuleInputCtor = []>(...args: ConstructorParameters<typeof Pointeract<M>>) => Pointeract<M> & Augmentation<M>;
16
+ export type PointeractInterface<M extends ModuleInput = []> = Pointeract<never> & Augmentation<M>;
17
+ declare const _default: PointeractType;
18
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { GeneralObject } from './declarations';
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[];
package/package.json CHANGED
@@ -1,54 +1,66 @@
1
1
  {
2
- "name": "pointeract",
3
- "version": "1.0.1",
4
- "description": "Modern, lightweight, robust and extensible user interaction resolver.",
5
- "main": "./dist/index.cjs",
6
- "module": "./dist/index.js",
7
- "types": "./dist/types/index.d.ts",
8
- "type": "module",
9
- "scripts": {
10
- "build": "vite build && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
11
- "test": "vitest run",
12
- "lint": "biome check --write",
13
- "test:coverage": "vitest run --coverage",
14
- "check": "tsc && biome check",
15
- "dev": "vite",
16
- "docs:dev": "vitepress dev docs",
17
- "docs:build": "vitepress build docs",
18
- "docs:preview": "vitepress preview docs"
19
- },
20
- "repository": {
21
- "type": "git",
22
- "url": "git+https://github.com/Hesprs/Pointeract.git"
23
- },
24
- "homepage": "https://pointeract.consensia.cc",
25
- "bugs": {
26
- "url": "https://github.com/Hesprs/Pointeract/issues"
27
- },
28
- "files": ["dist"],
29
- "publishConfig": {
30
- "provenance": true,
31
- "access": "public"
32
- },
33
- "keywords": ["frontend", "pointer-events", "interaction", "TypeScript"],
34
- "author": {
35
- "name": "Hēsperus",
36
- "email": "hesprs@outlook.com"
37
- },
38
- "license": "MIT",
39
- "packageManager": "pnpm@10.23.0",
40
- "devDependencies": {
41
- "@biomejs/biome": "^2.3.10",
42
- "@types/node": "^25.0.3",
43
- "@vitest/coverage-v8": "^4.0.16",
44
- "happy-dom": "^20.0.11",
45
- "terser": "^5.44.1",
46
- "tsc-alias": "^1.8.16",
47
- "typescript": "^5.9.3",
48
- "vite": "^7.3.0",
49
- "vitepress": "2.0.0-alpha.15",
50
- "vitepress-plugin-group-icons": "^1.6.5",
51
- "vitest": "^4.0.16",
52
- "vue": "^3.5.26"
53
- }
54
- }
2
+ "name": "pointeract",
3
+ "version": "1.1.1",
4
+ "description": "Modern, lightweight, robust and extensible user gesture recognizer.",
5
+ "keywords": [
6
+ "frontend",
7
+ "interaction",
8
+ "pointer-events",
9
+ "typescript"
10
+ ],
11
+ "homepage": "https://pointeract.consensia.cc",
12
+ "bugs": {
13
+ "url": "https://github.com/hesprs/pointeract/issues"
14
+ },
15
+ "license": "MIT",
16
+ "author": {
17
+ "name": "Hēsperus",
18
+ "email": "hesprs@outlook.com"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/hesprs/pointeract.git"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "type": "module",
28
+ "sideEffects": false,
29
+ "main": "./dist/index.js",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/types/index.d.ts",
32
+ "unpkg": "./dist/index.js",
33
+ "jsdelivr": "./dist/index.js",
34
+ "publishConfig": {
35
+ "access": "public",
36
+ "provenance": true
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^25.2.0",
40
+ "@vitest/coverage-v8": "^4.0.18",
41
+ "happy-dom": "^20.5.0",
42
+ "oxfmt": "^0.28.0",
43
+ "oxlint": "^1.43.0",
44
+ "oxlint-tsgolint": "^0.11.4",
45
+ "terser": "^5.46.0",
46
+ "tsc-alias": "^1.8.16",
47
+ "typescript": "^5.9.3",
48
+ "vite": "^7.3.1",
49
+ "vitepress": "2.0.0-alpha.16",
50
+ "vitepress-plugin-group-icons": "^1.7.1",
51
+ "vitest": "^4.0.18",
52
+ "vue": "^3.5.27",
53
+ "vue-tsc": "^3.2.4"
54
+ },
55
+ "scripts": {
56
+ "build": "vite build && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
57
+ "test": "vitest run",
58
+ "lint": "oxlint --type-aware --fix && oxfmt",
59
+ "test:coverage": "vitest run --coverage",
60
+ "check": "vue-tsc && oxfmt --check && oxlint --type-aware",
61
+ "dev": "vite",
62
+ "docs:dev": "vitepress dev docs",
63
+ "docs:build": "vitepress build docs",
64
+ "docs:preview": "vitepress preview docs"
65
+ }
66
+ }
package/dist/index.cjs DELETED
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class t{utils;window;pointers;monitoringElement;constructor(t,e,i,o){this.utils=t,this.window=e,this.pointers=i,this.monitoringElement=o}options;dispose;modifier;onPointerDown;onPointerMove;onPointerUp;onWheel;onStart;onStop}class e extends EventTarget{#t;#e=new Map;#i={};#o={};#s;options;get#n(){if(!this.#s)throw new Error("[Pointeract] Window is not defined.");return this.#s}constructor(t,e,o={}){super();const s=i(e||[]);this.#s=t.ownerDocument.defaultView,this.#t=t,this.options=o,this.#r({coordinateOutput:"relative"}),s.forEach(t=>{const e=new t(this.moduleUtils,this.#n,this.#e,this.#t);e.options&&this.#r(e.options),Object.assign(e,{options:o}),this.#i[t.name]=e})}#r=t=>{for(const[e,i]of Object.entries(t))e in this.options||(this.options[e]=i)};on=(t,e)=>(super.addEventListener(t,e),()=>this.off(t,e));off(t,e){super.removeEventListener(t,e)}moduleUtils={getNthValue:t=>{const e=new Error("[Pointeract] Invalid pointer index");if(t<0||t>=this.#e.size)throw e;let i=0;for(const o of this.#e.values()){if(i===t)return o;i++}throw e},screenToTarget:t=>{if("absolute"===this.options.coordinateOutput)return t;const e=this.#t.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,e)=>{let i,o=!0;for(const s of Object.values(this.#i))if(s.modifier&&(o=s.modifier(t,e),!0!==o))break;!1!==o&&(i=!0===o?new CustomEvent(t,{detail:e}):new CustomEvent(o.name,{detail:o.detail}),this.dispatchEvent(i))},getLast:(t,e=0)=>t[t.length-1-e]};#h(t,...e){Object.values(this.#i).forEach(i=>{i[t]&&i[t](...e)})}#a=t=>{if(this.#e.size>=2)return;t.isPrimary&&this.#e.clear();const e={records:[{x:t.clientX,y:t.clientY,timestamp:Date.now()}],target:t.target};this.#e.set(t.pointerId,e),this.#h("onPointerDown",t,e,this.#e)};#l=t=>{const e=this.#e.get(t.pointerId);e&&(e.records.push({x:t.clientX,y:t.clientY,timestamp:Date.now()}),this.#h("onPointerMove",t,e,this.#e))};#c=t=>{const e=this.#e.get(t.pointerId);e&&(this.#e.delete(t.pointerId),this.#h("onPointerUp",t,e,this.#e))};#p=t=>this.#h("onWheel",t);stop=t=>{const e=t=>{if(!(t.name in this.#i))return;const e=this.#i[t.name];e.onStop&&e.onStop(),this.#o[t.name]=e,delete this.#i[t.name]};return t?i(t).forEach(t=>{e(t)}):(()=>{this.#t.removeEventListener("pointerdown",this.#a),this.#n.removeEventListener("pointermove",this.#l),this.#n.removeEventListener("pointerup",this.#c),this.#t.removeEventListener("wheel",this.#p),this.#h("onStop")})(),this};start=t=>{const e=t=>{if(!(t.name in this.#o))return;const e=this.#o[t.name];e.onStart&&e.onStart(),this.#i[t.name]=e,delete this.#o[t.name]};return t?i(t).forEach(t=>{e(t)}):(()=>{this.#t.addEventListener("pointerdown",this.#a),this.#n.addEventListener("pointermove",this.#l),this.#n.addEventListener("pointerup",this.#c),this.#t.addEventListener("wheel",this.#p),this.#h("onStart")})(),this};dispose=()=>{this.stop(),this.#s=null,this.#h("dispose")}}const i=t=>Array.isArray(t)?t:[t];exports.BaseModule=t,exports.Click=class extends t{#d=-1/0;#u=0;options={clickPreserveTime:400,moveThreshold:5};onPointerDown=(t,e,i)=>{if(2===i.size){this.utils.getNthValue(0).interrupted=!0,e.interrupted=!0}};onPointerUp=(t,e)=>{if(e.interrupted)return;const i=this.options.moveThreshold;if(Math.abs(e.records[0].x-t.clientX)>=i||Math.abs(e.records[0].y-t.clientY)>=i)return;const o=this.utils.getLast(e.records).timestamp;o-this.#d<=this.options.clickPreserveTime?this.#u++:this.#u=1,this.#d=o;const s=this.utils.screenToTarget({x:t.clientX,y:t.clientY});this.utils.dispatch("trueClick",{...s,target:e.target,streak:this.#u})}},exports.Drag=class extends t{onPointerMove=(t,e,i)=>{const o=this.utils.getLast(e.records,1);if(1===i.size){const e=t.clientX-o.x,i=t.clientY-o.y;this.utils.dispatch("drag",{x:e,y:i,clientX:t.clientX,clientY:t.clientY})}}},exports.MultitouchPanZoom=class extends t{#m={lastDistance:0,lastMidpoint:{x:0,y:0}};#v(){const t=this.utils.getLast(this.utils.getNthValue(0).records),e=this.utils.getLast(this.utils.getNthValue(1).records),i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}#g(){const t=this.utils.getLast(this.utils.getNthValue(0).records),e=this.utils.getLast(this.utils.getNthValue(1).records);return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}onPointerDown=(t,e,i)=>{2===i.size&&(this.#m.lastDistance=this.#v(),this.#m.lastMidpoint=this.utils.screenToTarget(this.#g()))};onPointerMove=(t,e,i)=>{if(2===i.size){const t=this.#v(),e=this.#g(),i=t/this.#m.lastDistance;this.#m.lastDistance=t;const o=this.utils.screenToTarget(e),s=o.x-this.#m.lastMidpoint.x,n=o.y-this.#m.lastMidpoint.y;this.#m.lastMidpoint=o,this.#w({x:s,y:n}),this.#f(i,o)}};#f(t,e){this.utils.dispatch("zoom",{x:e.x,y:e.y,factor:t})}#w(t){this.utils.dispatch("pan",t)}},exports.Pointeract=e,exports.PreventDefault=class extends t{onWheel=t=>t.preventDefault();#E=t=>t.preventDefault();onStart=()=>{this.monitoringElement.style.touchAction="none",this.monitoringElement.addEventListener("gesturestart",this.#E,{passive:!1}),this.monitoringElement.addEventListener("gesturechange",this.#E,{passive:!1})};onStop=()=>{this.monitoringElement.style.touchAction="",this.monitoringElement.removeEventListener("gesturestart",this.#E),this.monitoringElement.removeEventListener("gesturechange",this.#E)};dispose=this.onStop},exports.WheelPanZoom=class extends t{options={proControlSchema:!1,zoomFactor:.1,lockControlSchema:!1};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=t.deltaY>0?1-e.zoomFactor:1+e.zoomFactor,o=this.utils.screenToTarget({x:t.clientX,y:t.clientY});this.#f(i,o)}else t.shiftKey&&Math.abs(t.deltaX)<=Math.abs(t.deltaY)?this.#w({x:-t.deltaY,y:-t.deltaX}):this.#w({x:-t.deltaX,y:-t.deltaY});else{const i=1-e.zoomFactor/50*t.deltaY,o=this.utils.screenToTarget({x:t.clientX,y:t.clientY});this.#f(i,o)}};#f(t,e){this.utils.dispatch("zoom",{x:e.x,y:e.y,factor:t})}#w(t){this.utils.dispatch("pan",t)}};
2
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/baseModule.ts","../src/pointeract.ts","../src/modules/click.ts","../src/modules/drag.ts","../src/modules/multitouchPanZoom.ts","../src/modules/preventDefault.ts","../src/modules/wheelPanZoom.ts"],"sourcesContent":["import type { Constrain, GeneralObject, ModifierReturn, Pointer, Pointers, StdEvents } from '@/declarations';\nimport type Pointeract from '@/pointeract';\n\ntype IsAny<T> = 0 extends 1 & T ? true : false;\n\nexport default class BaseModule<Events extends StdEvents = StdEvents> {\n\tprotected utils: Omit<Pointeract<never>['moduleUtils'], 'dispatch'> & {\n\t\tdispatch: <T extends keyof Constrain<Events>>(\n\t\t\tname: T,\n\t\t\t...args: IsAny<Events[T]['detail']> extends false ? [detail: Events[T]['detail']] : []\n\t\t) => void;\n\t};\n\tprotected window: Window;\n\tprotected pointers: Pointers;\n\tprotected monitoringElement: HTMLElement;\n\tconstructor(\n\t\tutils: Pointeract<never>['moduleUtils'],\n\t\twindow: Window,\n\t\tpointers: Pointers,\n\t\tmonitoringElement: HTMLElement,\n\t) {\n\t\tthis.utils = utils as typeof this.utils;\n\t\tthis.window = window;\n\t\tthis.pointers = pointers;\n\t\tthis.monitoringElement = monitoringElement;\n\t}\n\tdeclare readonly events: Events;\n\n\toptions?: GeneralObject;\n\n\t// hooks\n\tdispose?: (...args: []) => void;\n\tmodifier?: (...args: [string, unknown]) => ModifierReturn;\n\tonPointerDown?: (...args: [PointerEvent, Pointer, Pointers]) => void;\n\tonPointerMove?: (...args: [PointerEvent, Pointer, Pointers]) => void;\n\tonPointerUp?: (...args: [PointerEvent, Pointer, Pointers]) => void;\n\tonWheel?: (...args: [WheelEvent]) => void;\n\tonStart?: (...args: []) => void;\n\tonStop?: (...args: []) => void;\n}\n","import type BaseModule from '@/baseModule';\nimport type {\n\tCoordinates,\n\tEventMap,\n\tGeneralArguments,\n\tGeneralObject,\n\tHooks,\n\tModifierReturn,\n\tModuleCtor,\n\tModuleInput,\n\tOptions,\n\tPointers,\n\tReloadable,\n} from '@/declarations';\n\nexport default class Pointeract<T extends ModuleInput = []> extends EventTarget {\n\t#monitoringElement: 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\toptions: GeneralObject;\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(monitoringElement: HTMLElement, _modules?: T, options: Options<T> = {}) {\n\t\tsuper();\n\t\tconst modules = toArray(_modules ? _modules : ([] as Array<ModuleCtor>));\n\t\tthis.#_window = monitoringElement.ownerDocument.defaultView;\n\t\tthis.#monitoringElement = monitoringElement;\n\t\tthis.options = options;\n\t\tthis.#fillIn({ coordinateOutput: 'relative' });\n\t\tmodules.forEach(module => {\n\t\t\tconst instance = new module(\n\t\t\t\tthis.moduleUtils,\n\t\t\t\tthis.#window,\n\t\t\t\tthis.#pointers,\n\t\t\t\tthis.#monitoringElement,\n\t\t\t);\n\t\t\tif (instance.options) this.#fillIn(instance.options);\n\t\t\tObject.assign(instance, { options });\n\t\t\tthis.#modules[module.name] = instance;\n\t\t});\n\t}\n\n\t#fillIn = (patch: GeneralObject) => {\n\t\tfor (const [k, v] of Object.entries(patch))\n\t\t\tif (!(k in this.options)) (this.options as GeneralObject)[k] = v;\n\t};\n\n\ton = <K extends keyof EventMap<T>>(type: K, listener: (event: EventMap<T>[K]) => void) => {\n\t\tsuper.addEventListener(type as string, listener as EventListener);\n\t\treturn () => this.off(type, listener);\n\t};\n\toff<K extends keyof EventMap<T>>(type: K, listener: (event: EventMap<T>[K]) => void) {\n\t\tsuper.removeEventListener(type as string, listener as EventListener);\n\t}\n\n\tdeclare readonly events: EventMap<T>;\n\n\tmoduleUtils = {\n\t\tgetNthValue: (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\tscreenToTarget: (raw: Coordinates) => {\n\t\t\tif (this.options.coordinateOutput === 'absolute') return raw;\n\t\t\tconst rect = this.#monitoringElement.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: <T>(name: string, detail?: T) => {\n\t\t\tlet lastResult: ModifierReturn = true;\n\t\t\tfor (const value of Object.values(this.#modules)) {\n\t\t\t\tif (!value.modifier) continue;\n\t\t\t\tlastResult = value.modifier(name, detail);\n\t\t\t\tif (lastResult !== true) break;\n\t\t\t}\n\t\t\tif (lastResult === false) return;\n\t\t\tlet event: CustomEvent;\n\t\t\tif (lastResult === true) event = new CustomEvent<T>(name, { detail });\n\t\t\telse event = new CustomEvent(lastResult.name, { detail: lastResult.detail });\n\t\t\tthis.dispatchEvent(event);\n\t\t},\n\n\t\tgetLast: <T>(arr: Array<T>, num: number = 0) => arr[arr.length - 1 - num],\n\t};\n\n\t#runHooks(field: Hooks, ...args: GeneralArguments) {\n\t\tObject.values(this.#modules).forEach(module => {\n\t\t\tif (module[field]) module[field](...args);\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.#monitoringElement.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.#monitoringElement.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.#monitoringElement.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.#monitoringElement.addEventListener('wheel', this.#onWheel);\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};\n}\n\nconst toArray = <T>(toTrans: T | Array<T>) => (Array.isArray(toTrans) ? toTrans : [toTrans]);\n","import BaseModule from '@/baseModule';\nimport type { Pointer, Pointers } from '@/declarations';\n\nexport default class Click extends BaseModule {\n\t#lastClickTime = -Infinity;\n\t#clickSteak = 0;\n\n\toptions = {\n\t\tclickPreserveTime: 400,\n\t\tmoveThreshold: 5,\n\t};\n\n\tonPointerDown = (_e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tconst pointer0 = this.utils.getNthValue(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;\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 = this.utils.getLast(pointer.records).timestamp;\n\t\tif (newLast - this.#lastClickTime <= this.options.clickPreserveTime) this.#clickSteak++;\n\t\telse this.#clickSteak = 1;\n\t\tthis.#lastClickTime = newLast;\n\t\tconst coords = this.utils.screenToTarget({ x: e.clientX, y: e.clientY });\n\t\tthis.utils.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 BaseModule from '@/baseModule';\nimport type { Pointer, Pointers } from '@/declarations';\n\nexport default class Drag extends BaseModule {\n\tonPointerMove = (e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tconst last = this.utils.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.utils.dispatch('drag', { x: dx, y: dy, clientX: e.clientX, clientY: e.clientY });\n\t\t}\n\t};\n}\n","import BaseModule from '@/baseModule';\nimport type { Coordinates, Pointer, Pointers } from '@/declarations';\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 = this.utils.getLast(this.utils.getNthValue(0).records);\n\t\tconst pointer1Coords = this.utils.getLast(this.utils.getNthValue(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 = this.utils.getLast(this.utils.getNthValue(0).records);\n\t\tconst pointer1Coords = this.utils.getLast(this.utils.getNthValue(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.utils.screenToTarget(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.utils.screenToTarget(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({ x: dx, y: dy });\n\t\t\tthis.#dispatchZoomEvent(zoomFactor, newMidpoint);\n\t\t}\n\t};\n\n\t#dispatchZoomEvent(factor: number, origin: Coordinates) {\n\t\tthis.utils.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: Coordinates) {\n\t\tthis.utils.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.monitoringElement.style.touchAction = 'none';\n\t\tthis.monitoringElement.addEventListener('gesturestart', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t\tthis.monitoringElement.addEventListener('gesturechange', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t};\n\n\tonStop = () => {\n\t\tthis.monitoringElement.style.touchAction = '';\n\t\tthis.monitoringElement.removeEventListener('gesturestart', this.#preventDefaultFunction);\n\t\tthis.monitoringElement.removeEventListener('gesturechange', this.#preventDefaultFunction);\n\t};\n\n\tdispose = this.onStop;\n}\n","import BaseModule from '@/baseModule';\nimport type { Coordinates } from '@/declarations';\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\nexport default class wheelPanZoom extends BaseModule {\n\toptions = {\n\t\tproControlSchema: false,\n\t\tzoomFactor: 0.1,\n\t\tlockControlSchema: false,\n\t};\n\n\tonWheel = (e: WheelEvent) => {\n\t\tconst options = this.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 = e.deltaY > 0 ? 1 - options.zoomFactor : 1 + options.zoomFactor;\n\t\t\t\tconst origin = this.utils.screenToTarget({ 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({ x: -e.deltaY, y: -e.deltaX });\n\t\t\telse this.#dispatchPanEvent({ x: -e.deltaX, y: -e.deltaY });\n\t\t} else {\n\t\t\tconst scaleFactor = 1 - (options.zoomFactor / 50) * e.deltaY;\n\t\t\tconst origin = this.utils.screenToTarget({ 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.utils.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: Coordinates) {\n\t\tthis.utils.dispatch('pan', diff);\n\t}\n}\n"],"names":["BaseModule","utils","window","pointers","monitoringElement","constructor","this","options","dispose","modifier","onPointerDown","onPointerMove","onPointerUp","onWheel","onStart","onStop","Pointeract","EventTarget","Map","modules","pausedModules","_window","Error","_modules","super","toArray","ownerDocument","defaultView","fillIn","coordinateOutput","forEach","module","instance","moduleUtils","Object","assign","name","patch","k","v","entries","on","type","listener","addEventListener","off","removeEventListener","getNthValue","n","error","size","i","value","values","screenToTarget","raw","rect","getBoundingClientRect","x","left","y","top","width","height","dispatch","detail","event","lastResult","CustomEvent","dispatchEvent","getLast","arr","num","length","runHooks","field","args","e","isPrimary","clear","pointer","records","clientX","clientY","timestamp","Date","now","target","set","pointerId","get","push","delete","stop","_toStop","stopModule","moduleCtor","stopPointeract","start","_toStart","startModule","startPointeract","toTrans","Array","isArray","lastClickTime","Infinity","clickSteak","clickPreserveTime","moveThreshold","_e","interrupted","threshold","Math","abs","newLast","coords","streak","last","dx","dy","pinchZoomState","lastDistance","lastMidpoint","getPointerDistance","pointer0Coords","pointer1Coords","sqrt","getPointerMidpoint","_pointer","newDistance","newMidpointOnScreen","zoomFactor","newMidpoint","dispatchPanEvent","dispatchZoomEvent","factor","origin","diff","preventDefault","preventDefaultFunction","style","touchAction","passive","proControlSchema","lockControlSchema","ctrlKey","shiftKey","deltaX","deltaY","scaleFactor"],"mappings":"gFAKA,MAAqBA,EACVC,MAMAC,OACAC,SACAC,kBACV,WAAAC,CACCJ,EACAC,EACAC,EACAC,GAEAE,KAAKL,MAAQA,EACbK,KAAKJ,OAASA,EACdI,KAAKH,SAAWA,EAChBG,KAAKF,kBAAoBA,CAC1B,CAGAG,QAGAC,QACAC,SACAC,cACAC,cACAC,YACAC,QACAC,QACAC,OCvBD,MAAqBC,UAA+CC,YACnEb,GACAD,OAA0Be,IAC1BC,GAAuC,CAAA,EACvCC,GAA6C,CAAA,EAC7CC,GACAd,QAEA,KAAIL,GACH,IAAKI,MAAKe,EAAU,MAAM,IAAIC,MAAM,uCACpC,OAAOhB,MAAKe,CACb,CAEA,WAAAhB,CAAYD,EAAgCmB,EAAchB,EAAsB,CAAA,GAC/EiB,QACA,MAAML,EAAUM,EAAQF,GAAuB,IAC/CjB,MAAKe,EAAWjB,EAAkBsB,cAAcC,YAChDrB,MAAKF,EAAqBA,EAC1BE,KAAKC,QAAUA,EACfD,MAAKsB,EAAQ,CAAEC,iBAAkB,aACjCV,EAAQW,QAAQC,IACf,MAAMC,EAAW,IAAID,EACpBzB,KAAK2B,YACL3B,MAAKJ,EACLI,MAAKH,EACLG,MAAKF,GAEF4B,EAASzB,SAASD,MAAKsB,EAAQI,EAASzB,SAC5C2B,OAAOC,OAAOH,EAAU,CAAEzB,YAC1BD,MAAKa,EAASY,EAAOK,MAAQJ,GAE/B,CAEAJ,GAAWS,IACV,IAAA,MAAYC,EAAGC,KAAML,OAAOM,QAAQH,GAC7BC,KAAKhC,KAAKC,UAAWD,KAAKC,QAA0B+B,GAAKC,IAGjEE,GAAK,CAA8B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+D,SAAS,OAAQ,CAAEN,EAAG+E,EAAO/E,EAAGE,EAAG6E,EAAO7E,EAAG4E,UACzD,CAEA,EAAAF,CAAkBI,GACjBpI,KAAKL,MAAM+D,SAAS,MAAO0E,EAC5B"}
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- class t{utils;window;pointers;monitoringElement;constructor(t,e,i,o){this.utils=t,this.window=e,this.pointers=i,this.monitoringElement=o}options;dispose;modifier;onPointerDown;onPointerMove;onPointerUp;onWheel;onStart;onStop}class e extends t{#t=-1/0;#e=0;options={clickPreserveTime:400,moveThreshold:5};onPointerDown=(t,e,i)=>{if(2===i.size){this.utils.getNthValue(0).interrupted=!0,e.interrupted=!0}};onPointerUp=(t,e)=>{if(e.interrupted)return;const i=this.options.moveThreshold;if(Math.abs(e.records[0].x-t.clientX)>=i||Math.abs(e.records[0].y-t.clientY)>=i)return;const o=this.utils.getLast(e.records).timestamp;o-this.#t<=this.options.clickPreserveTime?this.#e++:this.#e=1,this.#t=o;const n=this.utils.screenToTarget({x:t.clientX,y:t.clientY});this.utils.dispatch("trueClick",{...n,target:e.target,streak:this.#e})}}class i extends t{onPointerMove=(t,e,i)=>{const o=this.utils.getLast(e.records,1);if(1===i.size){const e=t.clientX-o.x,i=t.clientY-o.y;this.utils.dispatch("drag",{x:e,y:i,clientX:t.clientX,clientY:t.clientY})}}}class o extends t{#i={lastDistance:0,lastMidpoint:{x:0,y:0}};#o(){const t=this.utils.getLast(this.utils.getNthValue(0).records),e=this.utils.getLast(this.utils.getNthValue(1).records),i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}#n(){const t=this.utils.getLast(this.utils.getNthValue(0).records),e=this.utils.getLast(this.utils.getNthValue(1).records);return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}onPointerDown=(t,e,i)=>{2===i.size&&(this.#i.lastDistance=this.#o(),this.#i.lastMidpoint=this.utils.screenToTarget(this.#n()))};onPointerMove=(t,e,i)=>{if(2===i.size){const t=this.#o(),e=this.#n(),i=t/this.#i.lastDistance;this.#i.lastDistance=t;const o=this.utils.screenToTarget(e),n=o.x-this.#i.lastMidpoint.x,s=o.y-this.#i.lastMidpoint.y;this.#i.lastMidpoint=o,this.#s({x:n,y:s}),this.#r(i,o)}};#r(t,e){this.utils.dispatch("zoom",{x:e.x,y:e.y,factor:t})}#s(t){this.utils.dispatch("pan",t)}}class n extends t{onWheel=t=>t.preventDefault();#h=t=>t.preventDefault();onStart=()=>{this.monitoringElement.style.touchAction="none",this.monitoringElement.addEventListener("gesturestart",this.#h,{passive:!1}),this.monitoringElement.addEventListener("gesturechange",this.#h,{passive:!1})};onStop=()=>{this.monitoringElement.style.touchAction="",this.monitoringElement.removeEventListener("gesturestart",this.#h),this.monitoringElement.removeEventListener("gesturechange",this.#h)};dispose=this.onStop}class s extends t{options={proControlSchema:!1,zoomFactor:.1,lockControlSchema:!1};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=t.deltaY>0?1-e.zoomFactor:1+e.zoomFactor,o=this.utils.screenToTarget({x:t.clientX,y:t.clientY});this.#r(i,o)}else t.shiftKey&&Math.abs(t.deltaX)<=Math.abs(t.deltaY)?this.#s({x:-t.deltaY,y:-t.deltaX}):this.#s({x:-t.deltaX,y:-t.deltaY});else{const i=1-e.zoomFactor/50*t.deltaY,o=this.utils.screenToTarget({x:t.clientX,y:t.clientY});this.#r(i,o)}};#r(t,e){this.utils.dispatch("zoom",{x:e.x,y:e.y,factor:t})}#s(t){this.utils.dispatch("pan",t)}}class r extends EventTarget{#a;#l=/* @__PURE__ */new Map;#c={};#d={};#p;options;get#u(){if(!this.#p)throw new Error("[Pointeract] Window is not defined.");return this.#p}constructor(t,e,i={}){super();const o=h(e||[]);this.#p=t.ownerDocument.defaultView,this.#a=t,this.options=i,this.#m({coordinateOutput:"relative"}),o.forEach(t=>{const e=new t(this.moduleUtils,this.#u,this.#l,this.#a);e.options&&this.#m(e.options),Object.assign(e,{options:i}),this.#c[t.name]=e})}#m=t=>{for(const[e,i]of Object.entries(t))e in this.options||(this.options[e]=i)};on=(t,e)=>(super.addEventListener(t,e),()=>this.off(t,e));off(t,e){super.removeEventListener(t,e)}moduleUtils={getNthValue:t=>{const e=new Error("[Pointeract] Invalid pointer index");if(t<0||t>=this.#l.size)throw e;let i=0;for(const o of this.#l.values()){if(i===t)return o;i++}throw e},screenToTarget:t=>{if("absolute"===this.options.coordinateOutput)return t;const e=this.#a.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,e)=>{let i,o=!0;for(const n of Object.values(this.#c))if(n.modifier&&(o=n.modifier(t,e),!0!==o))break;!1!==o&&(i=!0===o?new CustomEvent(t,{detail:e}):new CustomEvent(o.name,{detail:o.detail}),this.dispatchEvent(i))},getLast:(t,e=0)=>t[t.length-1-e]};#v(t,...e){Object.values(this.#c).forEach(i=>{i[t]&&i[t](...e)})}#g=t=>{if(this.#l.size>=2)return;t.isPrimary&&this.#l.clear();const e={records:[{x:t.clientX,y:t.clientY,timestamp:Date.now()}],target:t.target};this.#l.set(t.pointerId,e),this.#v("onPointerDown",t,e,this.#l)};#w=t=>{const e=this.#l.get(t.pointerId);e&&(e.records.push({x:t.clientX,y:t.clientY,timestamp:Date.now()}),this.#v("onPointerMove",t,e,this.#l))};#E=t=>{const e=this.#l.get(t.pointerId);e&&(this.#l.delete(t.pointerId),this.#v("onPointerUp",t,e,this.#l))};#f=t=>this.#v("onWheel",t);stop=t=>{const e=t=>{if(!(t.name in this.#c))return;const e=this.#c[t.name];e.onStop&&e.onStop(),this.#d[t.name]=e,delete this.#c[t.name]};return t?h(t).forEach(t=>{e(t)}):(()=>{this.#a.removeEventListener("pointerdown",this.#g),this.#u.removeEventListener("pointermove",this.#w),this.#u.removeEventListener("pointerup",this.#E),this.#a.removeEventListener("wheel",this.#f),this.#v("onStop")})(),this};start=t=>{const e=t=>{if(!(t.name in this.#d))return;const e=this.#d[t.name];e.onStart&&e.onStart(),this.#c[t.name]=e,delete this.#d[t.name]};return t?h(t).forEach(t=>{e(t)}):(()=>{this.#a.addEventListener("pointerdown",this.#g),this.#u.addEventListener("pointermove",this.#w),this.#u.addEventListener("pointerup",this.#E),this.#a.addEventListener("wheel",this.#f),this.#v("onStart")})(),this};dispose=()=>{this.stop(),this.#p=null,this.#v("dispose")}}const h=t=>Array.isArray(t)?t:[t];export{t as BaseModule,e as Click,i as Drag,o as MultitouchPanZoom,r as Pointeract,n as PreventDefault,s as WheelPanZoom};
2
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/baseModule.ts","../src/modules/click.ts","../src/modules/drag.ts","../src/modules/multitouchPanZoom.ts","../src/modules/preventDefault.ts","../src/modules/wheelPanZoom.ts","../src/pointeract.ts"],"sourcesContent":["import type { Constrain, GeneralObject, ModifierReturn, Pointer, Pointers, StdEvents } from '@/declarations';\nimport type Pointeract from '@/pointeract';\n\ntype IsAny<T> = 0 extends 1 & T ? true : false;\n\nexport default class BaseModule<Events extends StdEvents = StdEvents> {\n\tprotected utils: Omit<Pointeract<never>['moduleUtils'], 'dispatch'> & {\n\t\tdispatch: <T extends keyof Constrain<Events>>(\n\t\t\tname: T,\n\t\t\t...args: IsAny<Events[T]['detail']> extends false ? [detail: Events[T]['detail']] : []\n\t\t) => void;\n\t};\n\tprotected window: Window;\n\tprotected pointers: Pointers;\n\tprotected monitoringElement: HTMLElement;\n\tconstructor(\n\t\tutils: Pointeract<never>['moduleUtils'],\n\t\twindow: Window,\n\t\tpointers: Pointers,\n\t\tmonitoringElement: HTMLElement,\n\t) {\n\t\tthis.utils = utils as typeof this.utils;\n\t\tthis.window = window;\n\t\tthis.pointers = pointers;\n\t\tthis.monitoringElement = monitoringElement;\n\t}\n\tdeclare readonly events: Events;\n\n\toptions?: GeneralObject;\n\n\t// hooks\n\tdispose?: (...args: []) => void;\n\tmodifier?: (...args: [string, unknown]) => ModifierReturn;\n\tonPointerDown?: (...args: [PointerEvent, Pointer, Pointers]) => void;\n\tonPointerMove?: (...args: [PointerEvent, Pointer, Pointers]) => void;\n\tonPointerUp?: (...args: [PointerEvent, Pointer, Pointers]) => void;\n\tonWheel?: (...args: [WheelEvent]) => void;\n\tonStart?: (...args: []) => void;\n\tonStop?: (...args: []) => void;\n}\n","import BaseModule from '@/baseModule';\nimport type { Pointer, Pointers } from '@/declarations';\n\nexport default class Click extends BaseModule {\n\t#lastClickTime = -Infinity;\n\t#clickSteak = 0;\n\n\toptions = {\n\t\tclickPreserveTime: 400,\n\t\tmoveThreshold: 5,\n\t};\n\n\tonPointerDown = (_e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tif (pointers.size === 2) {\n\t\t\tconst pointer0 = this.utils.getNthValue(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;\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 = this.utils.getLast(pointer.records).timestamp;\n\t\tif (newLast - this.#lastClickTime <= this.options.clickPreserveTime) this.#clickSteak++;\n\t\telse this.#clickSteak = 1;\n\t\tthis.#lastClickTime = newLast;\n\t\tconst coords = this.utils.screenToTarget({ x: e.clientX, y: e.clientY });\n\t\tthis.utils.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 BaseModule from '@/baseModule';\nimport type { Pointer, Pointers } from '@/declarations';\n\nexport default class Drag extends BaseModule {\n\tonPointerMove = (e: PointerEvent, pointer: Pointer, pointers: Pointers) => {\n\t\tconst last = this.utils.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.utils.dispatch('drag', { x: dx, y: dy, clientX: e.clientX, clientY: e.clientY });\n\t\t}\n\t};\n}\n","import BaseModule from '@/baseModule';\nimport type { Coordinates, Pointer, Pointers } from '@/declarations';\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 = this.utils.getLast(this.utils.getNthValue(0).records);\n\t\tconst pointer1Coords = this.utils.getLast(this.utils.getNthValue(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 = this.utils.getLast(this.utils.getNthValue(0).records);\n\t\tconst pointer1Coords = this.utils.getLast(this.utils.getNthValue(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.utils.screenToTarget(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.utils.screenToTarget(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({ x: dx, y: dy });\n\t\t\tthis.#dispatchZoomEvent(zoomFactor, newMidpoint);\n\t\t}\n\t};\n\n\t#dispatchZoomEvent(factor: number, origin: Coordinates) {\n\t\tthis.utils.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: Coordinates) {\n\t\tthis.utils.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.monitoringElement.style.touchAction = 'none';\n\t\tthis.monitoringElement.addEventListener('gesturestart', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t\tthis.monitoringElement.addEventListener('gesturechange', this.#preventDefaultFunction, {\n\t\t\tpassive: false,\n\t\t});\n\t};\n\n\tonStop = () => {\n\t\tthis.monitoringElement.style.touchAction = '';\n\t\tthis.monitoringElement.removeEventListener('gesturestart', this.#preventDefaultFunction);\n\t\tthis.monitoringElement.removeEventListener('gesturechange', this.#preventDefaultFunction);\n\t};\n\n\tdispose = this.onStop;\n}\n","import BaseModule from '@/baseModule';\nimport type { Coordinates } from '@/declarations';\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\nexport default class wheelPanZoom extends BaseModule {\n\toptions = {\n\t\tproControlSchema: false,\n\t\tzoomFactor: 0.1,\n\t\tlockControlSchema: false,\n\t};\n\n\tonWheel = (e: WheelEvent) => {\n\t\tconst options = this.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 = e.deltaY > 0 ? 1 - options.zoomFactor : 1 + options.zoomFactor;\n\t\t\t\tconst origin = this.utils.screenToTarget({ 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({ x: -e.deltaY, y: -e.deltaX });\n\t\t\telse this.#dispatchPanEvent({ x: -e.deltaX, y: -e.deltaY });\n\t\t} else {\n\t\t\tconst scaleFactor = 1 - (options.zoomFactor / 50) * e.deltaY;\n\t\t\tconst origin = this.utils.screenToTarget({ 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.utils.dispatch('zoom', { x: origin.x, y: origin.y, factor });\n\t}\n\n\t#dispatchPanEvent(diff: Coordinates) {\n\t\tthis.utils.dispatch('pan', diff);\n\t}\n}\n","import type BaseModule from '@/baseModule';\nimport type {\n\tCoordinates,\n\tEventMap,\n\tGeneralArguments,\n\tGeneralObject,\n\tHooks,\n\tModifierReturn,\n\tModuleCtor,\n\tModuleInput,\n\tOptions,\n\tPointers,\n\tReloadable,\n} from '@/declarations';\n\nexport default class Pointeract<T extends ModuleInput = []> extends EventTarget {\n\t#monitoringElement: 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\toptions: GeneralObject;\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(monitoringElement: HTMLElement, _modules?: T, options: Options<T> = {}) {\n\t\tsuper();\n\t\tconst modules = toArray(_modules ? _modules : ([] as Array<ModuleCtor>));\n\t\tthis.#_window = monitoringElement.ownerDocument.defaultView;\n\t\tthis.#monitoringElement = monitoringElement;\n\t\tthis.options = options;\n\t\tthis.#fillIn({ coordinateOutput: 'relative' });\n\t\tmodules.forEach(module => {\n\t\t\tconst instance = new module(\n\t\t\t\tthis.moduleUtils,\n\t\t\t\tthis.#window,\n\t\t\t\tthis.#pointers,\n\t\t\t\tthis.#monitoringElement,\n\t\t\t);\n\t\t\tif (instance.options) this.#fillIn(instance.options);\n\t\t\tObject.assign(instance, { options });\n\t\t\tthis.#modules[module.name] = instance;\n\t\t});\n\t}\n\n\t#fillIn = (patch: GeneralObject) => {\n\t\tfor (const [k, v] of Object.entries(patch))\n\t\t\tif (!(k in this.options)) (this.options as GeneralObject)[k] = v;\n\t};\n\n\ton = <K extends keyof EventMap<T>>(type: K, listener: (event: EventMap<T>[K]) => void) => {\n\t\tsuper.addEventListener(type as string, listener as EventListener);\n\t\treturn () => this.off(type, listener);\n\t};\n\toff<K extends keyof EventMap<T>>(type: K, listener: (event: EventMap<T>[K]) => void) {\n\t\tsuper.removeEventListener(type as string, listener as EventListener);\n\t}\n\n\tdeclare readonly events: EventMap<T>;\n\n\tmoduleUtils = {\n\t\tgetNthValue: (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\tscreenToTarget: (raw: Coordinates) => {\n\t\t\tif (this.options.coordinateOutput === 'absolute') return raw;\n\t\t\tconst rect = this.#monitoringElement.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: <T>(name: string, detail?: T) => {\n\t\t\tlet lastResult: ModifierReturn = true;\n\t\t\tfor (const value of Object.values(this.#modules)) {\n\t\t\t\tif (!value.modifier) continue;\n\t\t\t\tlastResult = value.modifier(name, detail);\n\t\t\t\tif (lastResult !== true) break;\n\t\t\t}\n\t\t\tif (lastResult === false) return;\n\t\t\tlet event: CustomEvent;\n\t\t\tif (lastResult === true) event = new CustomEvent<T>(name, { detail });\n\t\t\telse event = new CustomEvent(lastResult.name, { detail: lastResult.detail });\n\t\t\tthis.dispatchEvent(event);\n\t\t},\n\n\t\tgetLast: <T>(arr: Array<T>, num: number = 0) => arr[arr.length - 1 - num],\n\t};\n\n\t#runHooks(field: Hooks, ...args: GeneralArguments) {\n\t\tObject.values(this.#modules).forEach(module => {\n\t\t\tif (module[field]) module[field](...args);\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.#monitoringElement.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.#monitoringElement.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.#monitoringElement.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.#monitoringElement.addEventListener('wheel', this.#onWheel);\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};\n}\n\nconst toArray = <T>(toTrans: T | Array<T>) => (Array.isArray(toTrans) ? toTrans : [toTrans]);\n"],"names":["BaseModule","utils","window","pointers","monitoringElement","constructor","this","options","dispose","modifier","onPointerDown","onPointerMove","onPointerUp","onWheel","onStart","onStop","Click","lastClickTime","Infinity","clickSteak","clickPreserveTime","moveThreshold","_e","pointer","size","getNthValue","interrupted","e","threshold","Math","abs","records","x","clientX","y","clientY","newLast","getLast","timestamp","coords","screenToTarget","dispatch","target","streak","Drag","last","dx","dy","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","proControlSchema","lockControlSchema","ctrlKey","shiftKey","deltaX","deltaY","scaleFactor","Pointeract","EventTarget","Map","modules","pausedModules","_window","Error","_modules","super","toArray","ownerDocument","defaultView","fillIn","coordinateOutput","forEach","module","instance","moduleUtils","Object","assign","name","patch","k","v","entries","on","type","listener","off","n","error","i","value","values","raw","rect","getBoundingClientRect","left","top","width","height","detail","event","lastResult","CustomEvent","dispatchEvent","arr","num","length","runHooks","field","args","isPrimary","clear","Date","now","set","pointerId","get","push","delete","stop","_toStop","stopModule","moduleCtor","stopPointeract","start","_toStart","startModule","startPointeract","toTrans","Array","isArray"],"mappings":"AAKA,MAAqBA,EACVC,MAMAC,OACAC,SACAC,kBACV,WAAAC,CACCJ,EACAC,EACAC,EACAC,GAEAE,KAAKL,MAAQA,EACbK,KAAKJ,OAASA,EACdI,KAAKH,SAAWA,EAChBG,KAAKF,kBAAoBA,CAC1B,CAGAG,QAGAC,QACAC,SACAC,cACAC,cACAC,YACAC,QACAC,QACAC,OCnCD,MAAqBC,UAAchB,EAClCiB,IAAiBC,IACjBC,GAAc,EAEdZ,QAAU,CACTa,kBAAmB,IACnBC,cAAe,GAGhBX,cAAgB,CAACY,EAAkBC,EAAkBpB,KACpD,GAAsB,IAAlBA,EAASqB,KAAY,CACPlB,KAAKL,MAAMwB,YAAY,GAI/BC,aAAc,EACvBH,EAAQG,aAAc,CACvB,GAGDd,YAAc,CAACe,EAAiBJ,KAC/B,GAAIA,EAAQG,YAAa,OACzB,MAAME,EAAYtB,KAAKC,QAAQc,cAC/B,GACCQ,KAAKC,IAAIP,EAAQQ,QAAQ,GAAGC,EAAIL,EAAEM,UAAYL,GAC9CC,KAAKC,IAAIP,EAAQQ,QAAQ,GAAGG,EAAIP,EAAEQ,UAAYP,EAE9C,OACD,MAAMQ,EAAU9B,KAAKL,MAAMoC,QAAQd,EAAQQ,SAASO,UAChDF,EAAU9B,MAAKW,GAAkBX,KAAKC,QAAQa,kBAAmBd,MAAKa,UAChEA,EAAc,EACxBb,MAAKW,EAAiBmB,EACtB,MAAMG,EAASjC,KAAKL,MAAMuC,eAAe,CAAER,EAAGL,EAAEM,QAASC,EAAGP,EAAEQ,UAC9D7B,KAAKL,MAAMwC,SAAS,YAAa,IAC7BF,EACHG,OAAQnB,EAAQmB,OAChBC,OAAQrC,MAAKa,KCpChB,MAAqByB,UAAa5C,EACjCW,cAAg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