pointeract 1.0.0 β 1.0.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 +23 -20
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/declarations.d.ts +21 -18
- package/dist/types/index.d.ts +1 -1
- package/dist/types/pointeract.d.ts +2 -2
- package/package.json +53 -55
package/README.md
CHANGED
|
@@ -20,8 +20,17 @@
|
|
|
20
20
|
<a href="https://pointeract.consensia.cc">
|
|
21
21
|
<img src="https://img.shields.io/badge/Documentation-Ready-333333?labelColor=5C73E7&logo=vitepress&logoColor=white" alt="Code Quality" />
|
|
22
22
|
</a>
|
|
23
|
+
<a href="https://www.npmjs.com/package/pointeract">
|
|
24
|
+
<img src="https://img.shields.io/npm/v/pointeract?logo=npm&labelColor=red&logoColor=white&color=333333" alt="npm package" />
|
|
25
|
+
</a>
|
|
26
|
+
<a href="https://snyk.io/test/npm/pointeract">
|
|
27
|
+
<img src="https://img.shields.io/badge/Snyk%20Security-Monitored-333333?logo=snyk&style=flat&labelColor=8A2BE2&logoColor=white" alt="library security" />
|
|
28
|
+
</a>
|
|
29
|
+
<a href="https://bundlephobia.com/package/pointeract">
|
|
30
|
+
<img src="https://img.shields.io/bundlephobia/minzip/pointeract?style=flat&logo=webpack&labelColor=orange&logoColor=white&color=333333&label=Minified+Gzipped%20Size" alt="package size" />
|
|
31
|
+
</a>
|
|
23
32
|
<img src="https://img.shields.io/badge/Types-Strict-333333?logo=typescript&labelColor=blue&logoColor=white" alt="Typescript" />
|
|
24
|
-
<img src="https://img.shields.io/badge/%F0%9F%96%90%EF%B8%8F%20Made%20by-Human-333333?labelColor=
|
|
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" />
|
|
25
34
|
</p>
|
|
26
35
|
|
|
27
36
|
<p align="center">
|
|
@@ -34,24 +43,18 @@
|
|
|
34
43
|
<a href="#license">License</a>
|
|
35
44
|
</p>
|
|
36
45
|
|
|
37
|
-
<!--
|
|
38
|
-
[](https://www.npmjs.com/package/pointeract)
|
|
39
|
-
[](https://bundlephobia.com/package/pointeract)
|
|
40
|
-
[](https://snyk.io/test/npm/pointeract)
|
|
41
|
-
-->
|
|
42
|
-
|
|
43
46
|
## What's Pointeract?
|
|
44
47
|
|
|
45
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.
|
|
46
49
|
|
|
47
|
-
It is
|
|
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.
|
|
48
51
|
|
|
49
52
|
Access our documentation [here](https://pointeract.consensia.cc/).
|
|
50
53
|
|
|
51
54
|
## Advantages
|
|
52
55
|
|
|
53
56
|
- **π£ Tiny**: With base **1KB** minified and gzipped, **1-2KB** for normal usage.
|
|
54
|
-
- **πͺ Robust**: Excels at complex gestures where most interaction libraries fail, [Why?](https://pointeract.consensia.cc/development/testing)
|
|
57
|
+
- **πͺ Robust**: Excels at complex gestures where most interaction libraries fail, [Why?](https://pointeract.consensia.cc/development/testing#chaotic-testing)
|
|
55
58
|
- **π§© Extensible**: Extend Pointeract effortlessly via our module API.
|
|
56
59
|
- **π Flexible during Runtime**: Options are updated reactively. Stop/start any module during runtime.
|
|
57
60
|
- **π‘οΈ Safe**: Not modifying the DOM (except the `PreventDefault` module). Meticulous clean up prevents memory leaks.
|
|
@@ -78,14 +81,14 @@ Or include the following lines directly in your HTML file:
|
|
|
78
81
|
|
|
79
82
|
```html
|
|
80
83
|
<script type="module">
|
|
81
|
-
|
|
84
|
+
import { Pointeract } from 'https://unpkg.com/pointeract/dist/index.js';
|
|
82
85
|
</script>
|
|
83
86
|
```
|
|
84
87
|
|
|
85
88
|
This link ships the latest ESM version by default, to access CJS version or earlier versions, try using a different URL like:
|
|
86
89
|
|
|
87
90
|
```html
|
|
88
|
-
<script src="https://unpkg.com/pointeract@1.0.0/dist/
|
|
91
|
+
<script src="https://unpkg.com/pointeract@1.0.0/dist/index.cjs"></script>
|
|
89
92
|
```
|
|
90
93
|
|
|
91
94
|
The link above ships version 1.0.0 in CJS.
|
|
@@ -105,15 +108,15 @@ Missing your desired interaction? [Write your own module](https://pointeract.con
|
|
|
105
108
|
|
|
106
109
|
There're already plenty of interaction libraries out there, most famous ones are `Interact.js` and `Hammer.js`, but Pointeract is different.
|
|
107
110
|
|
|
108
|
-
| Criteria
|
|
109
|
-
|
|
110
|
-
| Written in TypeScript?
|
|
111
|
-
| Tree-shakeable?
|
|
112
|
-
| Bundle Size (Minified + Gzipped)
|
|
113
|
-
| Last Updated
|
|
114
|
-
| Features
|
|
115
|
-
| Robust? (See [Testing](https://pointeract.consensia.cc/development/testing)) | β
| β Element Jerks | β Element Ignores the Second Touch |
|
|
116
|
-
| Extensible?
|
|
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? | β
| β | β |
|
|
117
120
|
|
|
118
121
|
## Get Involved
|
|
119
122
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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)}};
|
|
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
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\tConstructor,\n\tCoordinates,\n\tEventMap,\n\tGeneralArguments,\n\tGeneralObject,\n\tHooks,\n\tModifierReturn,\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);\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: Constructor<typeof BaseModule>) => {\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: Constructor<typeof BaseModule>) => {\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,UAA0CC,YAC9Db,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,EAAahB,EAAsB,CAAA,GAC9EiB,QACA,MAAML,EAAUM,EAAQF,GACxBjB,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,EAASz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IiB,EAAEwE,aAC5C,CACN,MAAMC,EAAc,EAAK/I,EAAQ6H,WAAa,GAAMvD,EAAEwE,OAChDZ,EAASnI,KAAKL,MAAMqD,eAAe,CAAEI,EAAGmB,EAAEK,QAAStB,EAAGiB,EAAEM,UAC9D7E,MAAKiI,EAAmBe,EAAab,EACtC,GAGD,EAAAF,CAAmBC,EAAgBC,GAClCnI,KAAKL,MAAM+D,SAAS,OAAQ,CAAEN,EAAG+E,EAAO/E,EAAGE,EAAG6E,EAAO7E,EAAG4E,UACzD,CAEA,EAAAF,CAAkBI,GACjBpI,KAAKL,MAAM+D,SAAS,MAAO0E,EAC5B"}
|
|
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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
|
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};
|
|
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
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\tConstructor,\n\tCoordinates,\n\tEventMap,\n\tGeneralArguments,\n\tGeneralObject,\n\tHooks,\n\tModifierReturn,\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);\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: Constructor<typeof BaseModule>) => {\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: Constructor<typeof BaseModule>) => {\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,IA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ACvDP,MAAK8H,EAAU,YASDoB,GAKRlJ,MAGRE,QAAU,KACTF,KAAK0I,OACL1I,MAAKkF,EAAW,KAChBlF,MAAK8H,EAAU,YAIjB,MAAMxC,EAAc6D,GAA2BC,MAAMC,QAAQF,GAAWA,EAAU,CAACA"}
|
|
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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5C,MAAQL,SAChC5F,MAAKgF,EAAS6D,EAAW5C,OAOjC,OALK0C,EAEJrD,EAAQqD,GAAShD,QAAQC,IACxBgD,EAAWhD,KAjBU,MACtB5F,MAAKF,EAAmBsE,oBAAoB,cAAepE,MAAKI,GAChEJ,MAAKJ,EAAQwE,oBAAoB,cAAepE,MAAKK,GACrDL,MAAKJ,EAAQwE,oBAAoB,YAAapE,MAAKM,GACnDN,MAAKF,EAAmBsE,oBAAoB,QAASpE,MAAKO,GAC1DP,MAAK8H,EAAU,WASFgB,GAKP9I,MAGR+I,MAASC,IACR,MAOMC,EAAeJ,IACpB,KAAMA,EAAW5C,QAAQjG,MAAKiF,GAAiB,OAC/C,MAAMW,EAAS5F,MAAKiF,EAAe4D,EAAW5C,MAC1CL,EAAOpF,SAASoF,EAAOpF,UAC3BR,MAAKgF,EAAS6D,EAAW5C,MAAQL,SAC1B5F,MAAKiF,EAAe4D,EAAW5C,OAOvC,OALK+C,EAEJ1D,EAAQ0D,GAAUrD,QAAQC,IACzBqD,EAAYrD,KAjBU,MACvB5F,MAAKF,EAAmBoE,iBAAiB,cAAelE,MAAKI,GAC7DJ,MAAKJ,EAAQsE,iBAAiB,cAAelE,MAAKK,GAClDL,MAAKJ,EAAQsE,iBAAiB,YAAalE,MAAKM,GAChDN,MAAKF,EAAmBoE,iBAAiB,QAASlE,MAAKO,GACvDP,MAAK8H,EAAU,YASDoB,GAKRlJ,MAGRE,QAAU,KACTF,KAAK0I,OACL1I,MAAKkF,EAAW,KAChBlF,MAAK8H,EAAU,YAIjB,MAAMxC,EAAc6D,GAA2BC,MAAMC,QAAQF,GAAWA,EAAU,CAACA"}
|
|
@@ -2,6 +2,27 @@ 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
|
+
type KnownKeys<T> = keyof {
|
|
7
|
+
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
8
|
+
};
|
|
9
|
+
export type Constrain<T> = Pick<T, KnownKeys<T>>;
|
|
10
|
+
type UndefinedToObject<T> = T extends undefined ? Empty : GeneralObject extends T ? Empty : T;
|
|
11
|
+
type WrapInArray<T> = T extends Array<infer U> ? Array<U> : [T];
|
|
12
|
+
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
|
+
};
|
|
5
26
|
export type Coordinates = {
|
|
6
27
|
x: number;
|
|
7
28
|
y: number;
|
|
@@ -16,25 +37,7 @@ export type Pointer = {
|
|
|
16
37
|
target: EventTarget | null;
|
|
17
38
|
[key: Indexable]: any;
|
|
18
39
|
};
|
|
19
|
-
export type Constructor<C extends abstract new (...args: any) => any> = new (...args: ConstructorParameters<C>) => InstanceType<C>;
|
|
20
|
-
type ModuleCtor = Constructor<typeof BaseModule>;
|
|
21
|
-
export type ModuleInput = Array<ModuleCtor> | ModuleCtor;
|
|
22
|
-
type UndefinedToObject<T> = T extends undefined ? {} : GeneralObject extends T ? {} : T;
|
|
23
|
-
type WrapInArray<T> = T extends Array<infer U> ? Array<U> : [T];
|
|
24
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
25
|
-
type AllModuleInstances<T extends ModuleInput> = InstanceType<WrapInArray<T>[number]>;
|
|
26
|
-
export type Options<T extends ModuleInput> = Partial<UnionToIntersection<UndefinedToObject<AllModuleInstances<T>['options']>> & BaseOptions>;
|
|
27
|
-
export type EventMap<T extends ModuleInput> = Constrain<UnionToIntersection<AllModuleInstances<T>['events']>>;
|
|
28
40
|
export type Hooks = 'onPointerDown' | 'onPointerUp' | 'onPointerMove' | 'onWheel' | 'onStart' | 'onStop' | 'dispose' | 'modifier';
|
|
29
|
-
export type Reloadable<T extends ModuleInput> = WrapInArray<T>[number];
|
|
30
|
-
export type ModifierReturn = true | false | {
|
|
31
|
-
name: string;
|
|
32
|
-
detail: unknown;
|
|
33
|
-
};
|
|
34
|
-
type KnownKeys<T> = keyof {
|
|
35
|
-
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
36
|
-
};
|
|
37
|
-
export type Constrain<T> = Pick<T, KnownKeys<T>>;
|
|
38
41
|
export interface StdEvents {
|
|
39
42
|
pan: CustomEvent<Coordinates>;
|
|
40
43
|
drag: CustomEvent<Coordinates & {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as BaseModule } from './baseModule';
|
|
2
|
-
export type { Coordinates, Options, Pointer, Pointers, StdEvents } from './declarations';
|
|
2
|
+
export type { Coordinates, Ctors, Options, Pointer, Pointers, StdEvents } 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';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Coordinates, EventMap, GeneralObject, ModuleInput, Options, Reloadable } from './declarations';
|
|
2
|
-
export default class Pointeract<T extends ModuleInput> extends EventTarget {
|
|
2
|
+
export default class Pointeract<T extends ModuleInput = []> extends EventTarget {
|
|
3
3
|
#private;
|
|
4
4
|
options: GeneralObject;
|
|
5
|
-
constructor(monitoringElement: HTMLElement, _modules
|
|
5
|
+
constructor(monitoringElement: HTMLElement, _modules?: T, options?: Options<T>);
|
|
6
6
|
on: <K extends keyof EventMap<T>>(type: K, listener: (event: EventMap<T>[K]) => void) => () => void;
|
|
7
7
|
off<K extends keyof EventMap<T>>(type: K, listener: (event: EventMap<T>[K]) => void): void;
|
|
8
8
|
readonly events: EventMap<T>;
|
package/package.json
CHANGED
|
@@ -1,56 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
}
|
|
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": "HeΜ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
|
+
}
|