@thi.ng/rstream-gestures 5.0.74 → 5.0.76
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/CHANGELOG.md +7 -1
- package/README.md +1 -1
- package/gesture-stream.js +9 -9
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-06-29T09:28:36Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [5.0.75](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream-gestures@5.0.75) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
|
|
17
|
+
|
|
12
18
|
### [5.0.71](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream-gestures@5.0.71) (2024-04-20)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 189 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
package/gesture-stream.js
CHANGED
|
@@ -61,7 +61,7 @@ const gestureStream = (el, _opts) => {
|
|
|
61
61
|
const isStart = etype === "mousedown" || etype === "touchstart";
|
|
62
62
|
for (let t of events) {
|
|
63
63
|
const id = t.identifier || 0;
|
|
64
|
-
const pos =
|
|
64
|
+
const pos = __getPos(t, bounds, opts.local, opts.scale);
|
|
65
65
|
let touch = active.find((t2) => t2.id === id);
|
|
66
66
|
if (!touch && isStart) {
|
|
67
67
|
touch = { id, start: pos };
|
|
@@ -81,7 +81,7 @@ const gestureStream = (el, _opts) => {
|
|
|
81
81
|
}
|
|
82
82
|
if (isStart && !tempStreams) {
|
|
83
83
|
tempStreams = tempEvents.map(
|
|
84
|
-
(id) =>
|
|
84
|
+
(id) => __eventSource(document.body, id, opts, "-temp")
|
|
85
85
|
);
|
|
86
86
|
stream.addAll(tempStreams);
|
|
87
87
|
!isBody && stream.removeID("mousemove");
|
|
@@ -98,7 +98,7 @@ const gestureStream = (el, _opts) => {
|
|
|
98
98
|
}
|
|
99
99
|
if (numTouches === 0) {
|
|
100
100
|
stream.removeAll(tempStreams);
|
|
101
|
-
!isBody && stream.add(
|
|
101
|
+
!isBody && stream.add(__eventSource(el, "mousemove", opts));
|
|
102
102
|
tempStreams = void 0;
|
|
103
103
|
}
|
|
104
104
|
};
|
|
@@ -109,7 +109,7 @@ const gestureStream = (el, _opts) => {
|
|
|
109
109
|
};
|
|
110
110
|
const stream = merge({
|
|
111
111
|
id: opts.id,
|
|
112
|
-
src: BASE_EVENTS.map((id) =>
|
|
112
|
+
src: BASE_EVENTS.map((id) => __eventSource(el, id, opts)),
|
|
113
113
|
xform: map((e) => {
|
|
114
114
|
const etype = e.type;
|
|
115
115
|
if (etype === "$zoom") {
|
|
@@ -129,7 +129,7 @@ const gestureStream = (el, _opts) => {
|
|
|
129
129
|
isTouch: false
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
|
-
const type =
|
|
132
|
+
const type = __classifyEventType(etype, !!tempStreams);
|
|
133
133
|
let isTouch = !!e.touches;
|
|
134
134
|
let events = isTouch ? Array.from(e.changedTouches) : [e];
|
|
135
135
|
const bounds = el.getBoundingClientRect();
|
|
@@ -140,7 +140,7 @@ const gestureStream = (el, _opts) => {
|
|
|
140
140
|
} else if (type === "zoom") {
|
|
141
141
|
updateZoom(e);
|
|
142
142
|
}
|
|
143
|
-
lastPos =
|
|
143
|
+
lastPos = __getPos(events[0], bounds, opts.local, opts.scale);
|
|
144
144
|
opts.preventDefault && e.preventDefault();
|
|
145
145
|
return {
|
|
146
146
|
event: e,
|
|
@@ -159,15 +159,15 @@ const gestureStream = (el, _opts) => {
|
|
|
159
159
|
}
|
|
160
160
|
return stream;
|
|
161
161
|
};
|
|
162
|
-
const
|
|
162
|
+
const __eventSource = (el, type, opts, suffix = "") => {
|
|
163
163
|
let eventOpts = opts.eventOpts;
|
|
164
164
|
if (type === "wheel" && opts.preventScrollOnZoom) {
|
|
165
165
|
eventOpts = isBoolean(eventOpts) ? { capture: eventOpts, passive: false } : { ...eventOpts, passive: false };
|
|
166
166
|
}
|
|
167
167
|
return fromDOMEvent(el, type, eventOpts, { id: type + suffix });
|
|
168
168
|
};
|
|
169
|
-
const
|
|
170
|
-
const
|
|
169
|
+
const __classifyEventType = (etype, isActive) => etype === "mousemove" ? isActive ? "drag" : "move" : EVENT_GESTURETYPES[etype];
|
|
170
|
+
const __getPos = (e, bounds, isLocal, doScale) => {
|
|
171
171
|
let x = e.clientX;
|
|
172
172
|
let y = e.clientY;
|
|
173
173
|
if (isLocal) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/rstream-gestures",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.76",
|
|
4
4
|
"description": "Unified mouse, mouse wheel & multi-touch event stream abstraction",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://thi.ng/rstream-gestures",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@thi.ng/api": "^8.11.
|
|
44
|
-
"@thi.ng/checks": "^3.6.
|
|
45
|
-
"@thi.ng/math": "^5.
|
|
46
|
-
"@thi.ng/rstream": "^8.5.
|
|
47
|
-
"@thi.ng/transducers": "^9.0.
|
|
43
|
+
"@thi.ng/api": "^8.11.4",
|
|
44
|
+
"@thi.ng/checks": "^3.6.6",
|
|
45
|
+
"@thi.ng/math": "^5.11.1",
|
|
46
|
+
"@thi.ng/rstream": "^8.5.2",
|
|
47
|
+
"@thi.ng/transducers": "^9.0.7"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@microsoft/api-extractor": "^7.
|
|
51
|
-
"esbuild": "^0.21.
|
|
50
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
51
|
+
"esbuild": "^0.21.5",
|
|
52
52
|
"typedoc": "^0.25.13",
|
|
53
|
-
"typescript": "^5.
|
|
53
|
+
"typescript": "^5.5.2"
|
|
54
54
|
},
|
|
55
55
|
"keywords": [
|
|
56
56
|
"animation",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
],
|
|
97
97
|
"year": 2018
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "7b950c112fba0b2e7c450765b15624c3382f1354\n"
|
|
100
100
|
}
|