@excom/gesture-handler 0.1.0
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/.rush/temp/chunked-rush-logs/gesture-handler.apply-exports.chunks.jsonl +1 -0
- package/.rush/temp/chunked-rush-logs/gesture-handler.build_docs.chunks.jsonl +1 -0
- package/.rush/temp/chunked-rush-logs/gesture-handler.build_package-metas.chunks.jsonl +1 -0
- package/.rush/temp/operation/apply-exports/all.log +1 -0
- package/.rush/temp/operation/apply-exports/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/apply-exports/state.json +3 -0
- package/.rush/temp/operation/build_docs/all.log +1 -0
- package/.rush/temp/operation/build_docs/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/build_docs/state.json +3 -0
- package/.rush/temp/operation/build_package-metas/all.log +1 -0
- package/.rush/temp/operation/build_package-metas/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/build_package-metas/state.json +3 -0
- package/.rush/temp/shrinkwrap-deps.json +3 -0
- package/config/rig.json +6 -0
- package/gesture-handler.ts +1211 -0
- package/index.css +5 -0
- package/index.ts +29 -0
- package/package.json +52 -0
- package/rush-logs/gesture-handler.apply-exports.cache.log +1 -0
- package/rush-logs/gesture-handler.apply-exports.log +1 -0
- package/rush-logs/gesture-handler.build_docs.cache.log +1 -0
- package/rush-logs/gesture-handler.build_docs.log +1 -0
- package/rush-logs/gesture-handler.build_package-metas.cache.log +1 -0
- package/rush-logs/gesture-handler.build_package-metas.log +1 -0
- package/src/gesture-handler.css +207 -0
- package/support/custom-elements.json +989 -0
- package/support/demos/carousel.html +44 -0
- package/support/demos/pinch.html +10 -0
- package/support/demos/sheet.html +50 -0
- package/support/demos/swipe.html +24 -0
- package/support/dist-docs/gesture-handler.md +339 -0
- package/support/docs/README.md +92 -0
- package/support/package-meta.json +489 -0
- package/support/tests/carousel.view.test.ts +67 -0
- package/support/tests/gesture-handler.test.ts +625 -0
- package/support/tests/pointer-utils.ts +62 -0
- package/support/tests/sheet.view.test.ts +112 -0
- package/support/tests/swipe.view.test.ts +44 -0
- package/tsconfig.json +5 -0
package/index.css
ADDED
package/index.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GestureHandler } from "./gesture-handler";
|
|
2
|
+
|
|
3
|
+
GestureHandler.define();
|
|
4
|
+
|
|
5
|
+
export { GestureHandler };
|
|
6
|
+
export type {
|
|
7
|
+
GestureHandlerCancelEvent,
|
|
8
|
+
GestureHandlerEndEvent,
|
|
9
|
+
GestureHandlerMoveEvent,
|
|
10
|
+
GestureHandlerPointEvent,
|
|
11
|
+
GestureHandlerProvision,
|
|
12
|
+
GestureHandlerSnapEvent,
|
|
13
|
+
GestureHandlerStartEvent,
|
|
14
|
+
GestureHandlerSwipeEvent,
|
|
15
|
+
GestureHandlerValues,
|
|
16
|
+
GestureType,
|
|
17
|
+
} from "./gesture-handler";
|
|
18
|
+
|
|
19
|
+
type T_HTMLGestureHandlerElement = typeof GestureHandler.CustomElement;
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLGestureHandlerElement extends T_HTMLGestureHandlerElement {}
|
|
22
|
+
interface Window {
|
|
23
|
+
HTMLGestureHandlerElement: HTMLGestureHandlerElement;
|
|
24
|
+
}
|
|
25
|
+
interface HTMLElementTagNameMap {
|
|
26
|
+
"gesture-handler": HTMLGestureHandlerElement;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export type { HTMLGestureHandlerElement };
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@excom/gesture-handler",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "<gesture-handler> custom element",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=24.13.0"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@excom/neutron": "^0.1.0",
|
|
12
|
+
"@excom/kit-utils": "^0.1.0"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@excom/content-carousel": "^0.1.0",
|
|
17
|
+
"@excom/content-drawer": "^0.1.0",
|
|
18
|
+
"@excom/event-handler": "^0.1.0",
|
|
19
|
+
"@excom/quark": "^0.1.0",
|
|
20
|
+
"@excom/heft-rig": "^0.1.0",
|
|
21
|
+
"@excom/quark-sheet": "^0.1.0"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"url": "excom-dev/nucleus",
|
|
25
|
+
"directory": "packages/gesture-handler"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/excom-dev/nucleus/tree/main/packages/gesture-handler/support/docs/README.md",
|
|
28
|
+
"bugs": "https://github.com/excom-dev/nucleus/issues",
|
|
29
|
+
"keywords": [
|
|
30
|
+
"gesture-handler",
|
|
31
|
+
"neutron",
|
|
32
|
+
"custom-elements",
|
|
33
|
+
"gestures",
|
|
34
|
+
"swipe",
|
|
35
|
+
"pinch",
|
|
36
|
+
"drag"
|
|
37
|
+
],
|
|
38
|
+
"excom": {
|
|
39
|
+
"packageType": "kit-element"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "node node_modules/@excom/heft-rig/scripts/vite-build.mjs",
|
|
43
|
+
"build:watch": "node node_modules/@excom/heft-rig/scripts/vite-build-watch.mjs",
|
|
44
|
+
"format": "node node_modules/@excom/heft-rig/scripts/format.mjs",
|
|
45
|
+
"test": "node node_modules/@excom/heft-rig/scripts/vitest.mjs",
|
|
46
|
+
"coverage": "node node_modules/@excom/heft-rig/scripts/coverage.mjs",
|
|
47
|
+
"dev": "node node_modules/@excom/heft-rig/scripts/vite-dev.mjs",
|
|
48
|
+
"preview": "node node_modules/@excom/heft-rig/scripts/vite-preview.mjs",
|
|
49
|
+
"build:package-metas": "node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs",
|
|
50
|
+
"build:docs": "node node_modules/@excom/heft-rig/scripts/build-docs.mjs"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Caching has been disabled for this project's "apply-exports" command.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Invoking: cd "$RUSH_PROJECT_FOLDER" && node ../heft-rig/scripts/apply-exports.mjs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This project does not define the caching behavior of the "build:docs" command, so caching has been disabled.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Invoking: node node_modules/@excom/heft-rig/scripts/build-docs.mjs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This project does not define the caching behavior of the "build:package-metas" command, so caching has been disabled.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Invoking: node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styles for `<gesture-handler>`.
|
|
3
|
+
* @element gesture-handler
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* Aliases */
|
|
7
|
+
@custom-selector :--gesture-handler gesture-handler, .tag-gesture-handler;
|
|
8
|
+
@custom-selector :--gesture-handler--is-active [is-active], [data-active];
|
|
9
|
+
|
|
10
|
+
@define-mixin module-gesture-handler {
|
|
11
|
+
/* Registered so it interpolates: the settle after release is a transition
|
|
12
|
+
on this property, not a script animating it frame by frame. */
|
|
13
|
+
@property --gesture-progress {
|
|
14
|
+
syntax: "<number>";
|
|
15
|
+
inherits: true;
|
|
16
|
+
initial-value: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The gesture surface. `touch-action` follows `gesture-types` so the
|
|
21
|
+
* browser keeps the scrolling the element does not claim: `pan-x` leaves
|
|
22
|
+
* vertical scroll native, `pan-y` horizontal, free `pan` / `pinch` /
|
|
23
|
+
* `rotate` take everything. Override it in your own CSS when needed.
|
|
24
|
+
*/
|
|
25
|
+
:--gesture-handler {
|
|
26
|
+
/**
|
|
27
|
+
* Pointer centroid inside the element (px), horizontal — spotlight / parallax effects. Written every frame of a gesture; this is the resting value.
|
|
28
|
+
* @cssproperty
|
|
29
|
+
* @syntax <length>
|
|
30
|
+
* @default 0px
|
|
31
|
+
*/
|
|
32
|
+
--gesture-x: 0px;
|
|
33
|
+
/**
|
|
34
|
+
* Pointer centroid inside the element (px), vertical.
|
|
35
|
+
* @cssproperty
|
|
36
|
+
* @syntax <length>
|
|
37
|
+
* @default 0px
|
|
38
|
+
*/
|
|
39
|
+
--gesture-y: 0px;
|
|
40
|
+
/**
|
|
41
|
+
* Horizontal travel since the gesture started (px) — drag-to-move, swipe-to-dismiss.
|
|
42
|
+
* @cssproperty
|
|
43
|
+
* @syntax <length>
|
|
44
|
+
* @default 0px
|
|
45
|
+
*/
|
|
46
|
+
--gesture-dx: 0px;
|
|
47
|
+
/**
|
|
48
|
+
* Vertical travel since the gesture started (px).
|
|
49
|
+
* @cssproperty
|
|
50
|
+
* @syntax <length>
|
|
51
|
+
* @default 0px
|
|
52
|
+
*/
|
|
53
|
+
--gesture-dy: 0px;
|
|
54
|
+
/**
|
|
55
|
+
* Horizontal velocity over the last ~100 ms (px/ms).
|
|
56
|
+
* @cssproperty
|
|
57
|
+
* @syntax <number>
|
|
58
|
+
* @default 0
|
|
59
|
+
*/
|
|
60
|
+
--gesture-vx: 0;
|
|
61
|
+
/**
|
|
62
|
+
* Vertical velocity over the last ~100 ms (px/ms).
|
|
63
|
+
* @cssproperty
|
|
64
|
+
* @syntax <number>
|
|
65
|
+
* @default 0
|
|
66
|
+
*/
|
|
67
|
+
--gesture-vy: 0;
|
|
68
|
+
/**
|
|
69
|
+
* Travel along `progress-axis` as a fraction of the range, clamped to `progress-min`..`progress-max` — the value a scrubbable sheet, carousel or slider follows. Persists after release until the next gesture.
|
|
70
|
+
* @cssproperty
|
|
71
|
+
* @syntax <number>
|
|
72
|
+
* @default 0
|
|
73
|
+
*/
|
|
74
|
+
--gesture-progress: 0;
|
|
75
|
+
/**
|
|
76
|
+
* The measured range (`range-ref` size along the axis, or `range-px`). Written once, when the gesture starts.
|
|
77
|
+
* @cssproperty
|
|
78
|
+
* @syntax <length>
|
|
79
|
+
* @default 0px
|
|
80
|
+
*/
|
|
81
|
+
--gesture-range-px: 0px;
|
|
82
|
+
/**
|
|
83
|
+
* The element's own width, measured when the gesture starts.
|
|
84
|
+
* @cssproperty
|
|
85
|
+
* @syntax <length>
|
|
86
|
+
* @default 0px
|
|
87
|
+
*/
|
|
88
|
+
--gesture-width: 0px;
|
|
89
|
+
/**
|
|
90
|
+
* The element's own height, measured when the gesture starts.
|
|
91
|
+
* @cssproperty
|
|
92
|
+
* @syntax <length>
|
|
93
|
+
* @default 0px
|
|
94
|
+
*/
|
|
95
|
+
--gesture-height: 0px;
|
|
96
|
+
/**
|
|
97
|
+
* Two-finger pinch ratio (`1` = unchanged) — pinch-to-zoom.
|
|
98
|
+
* @cssproperty
|
|
99
|
+
* @syntax <number>
|
|
100
|
+
* @default 1
|
|
101
|
+
*/
|
|
102
|
+
--gesture-scale: 1;
|
|
103
|
+
/**
|
|
104
|
+
* Two-finger rotation — rotate-to-adjust.
|
|
105
|
+
* @cssproperty
|
|
106
|
+
* @syntax <angle>
|
|
107
|
+
* @default 0deg
|
|
108
|
+
*/
|
|
109
|
+
--gesture-rotate: 0deg;
|
|
110
|
+
/**
|
|
111
|
+
* Pointers currently down.
|
|
112
|
+
* @cssproperty
|
|
113
|
+
* @syntax <integer>
|
|
114
|
+
* @default 0
|
|
115
|
+
*/
|
|
116
|
+
--gesture-pointers: 0;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Length of the travel (px). Computed from `--gesture-dx` / `--gesture-dy`.
|
|
120
|
+
* @cssproperty
|
|
121
|
+
* @syntax <length>
|
|
122
|
+
* @default hypot(var(--gesture-dx), var(--gesture-dy))
|
|
123
|
+
*/
|
|
124
|
+
--gesture-distance: hypot(var(--gesture-dx), var(--gesture-dy));
|
|
125
|
+
/**
|
|
126
|
+
* Direction of the travel: `0deg` right, `90deg` down. Computed from `--gesture-dx` / `--gesture-dy`.
|
|
127
|
+
* @cssproperty
|
|
128
|
+
* @syntax <angle>
|
|
129
|
+
* @default atan2(var(--gesture-dy), var(--gesture-dx))
|
|
130
|
+
*/
|
|
131
|
+
--gesture-angle: atan2(var(--gesture-dy), var(--gesture-dx));
|
|
132
|
+
/**
|
|
133
|
+
* `--gesture-progress` in px. Computed from `--gesture-progress` and `--gesture-range-px`.
|
|
134
|
+
* @cssproperty
|
|
135
|
+
* @syntax <length>
|
|
136
|
+
* @default calc(var(--gesture-progress) * var(--gesture-range-px))
|
|
137
|
+
*/
|
|
138
|
+
--gesture-progress-px: calc(
|
|
139
|
+
var(--gesture-progress) * var(--gesture-range-px)
|
|
140
|
+
);
|
|
141
|
+
/* `tan(atan2(a, b))` is `a / b`: dividing a length by a length is not
|
|
142
|
+
portable in `calc()`, the trig functions are. */
|
|
143
|
+
/**
|
|
144
|
+
* `--gesture-x` as a 0..1 fraction of the element's width. Computed from `--gesture-x` and `--gesture-width`.
|
|
145
|
+
* @cssproperty
|
|
146
|
+
* @syntax <number>
|
|
147
|
+
* @default tan(atan2(var(--gesture-x), var(--gesture-width)))
|
|
148
|
+
*/
|
|
149
|
+
--gesture-x-ratio: tan(atan2(var(--gesture-x), var(--gesture-width)));
|
|
150
|
+
/**
|
|
151
|
+
* `--gesture-y` as a 0..1 fraction of the element's height. Computed from `--gesture-y` and `--gesture-height`.
|
|
152
|
+
* @cssproperty
|
|
153
|
+
* @syntax <number>
|
|
154
|
+
* @default tan(atan2(var(--gesture-y), var(--gesture-height)))
|
|
155
|
+
*/
|
|
156
|
+
--gesture-y-ratio: tan(atan2(var(--gesture-y), var(--gesture-height)));
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* How long `--gesture-progress` takes to settle on its snap point after release.
|
|
160
|
+
* @cssproperty
|
|
161
|
+
* @syntax <time>
|
|
162
|
+
* @default 200ms
|
|
163
|
+
*/
|
|
164
|
+
--gesture-snap-duration: 200ms;
|
|
165
|
+
/**
|
|
166
|
+
* Easing of that settle.
|
|
167
|
+
* @cssproperty
|
|
168
|
+
* @syntax <easing-function>
|
|
169
|
+
* @default ease-out
|
|
170
|
+
*/
|
|
171
|
+
--gesture-snap-ease: ease-out;
|
|
172
|
+
|
|
173
|
+
display: block;
|
|
174
|
+
touch-action: pan-x pan-y pinch-zoom;
|
|
175
|
+
/* The release settles here, not in script; `gesture-handler-snap` fires
|
|
176
|
+
when this transition finishes. */
|
|
177
|
+
transition: --gesture-progress var(--gesture-snap-duration)
|
|
178
|
+
var(--gesture-snap-ease);
|
|
179
|
+
|
|
180
|
+
&[gesture-types~="pan-x"] {
|
|
181
|
+
touch-action: pan-y;
|
|
182
|
+
}
|
|
183
|
+
&[gesture-types~="pan-y"] {
|
|
184
|
+
touch-action: pan-x;
|
|
185
|
+
}
|
|
186
|
+
&:not([gesture-types]),
|
|
187
|
+
&[gesture-types~="pan"],
|
|
188
|
+
&[gesture-types~="pinch"],
|
|
189
|
+
&[gesture-types~="rotate"] {
|
|
190
|
+
touch-action: none;
|
|
191
|
+
}
|
|
192
|
+
/* `handoff-ref` needs its containers to scroll natively until they run
|
|
193
|
+
out — the element cancels the touch itself the moment the overscroll
|
|
194
|
+
hands over, so `touch-action` stays out of the way here. Give a
|
|
195
|
+
`from-ref` handle `touch-action: none` of its own. */
|
|
196
|
+
&[handoff-ref] {
|
|
197
|
+
touch-action: auto;
|
|
198
|
+
}
|
|
199
|
+
/* No text selection / image drag while a gesture is tracked, and never
|
|
200
|
+
ease the finger: the transition is only for the release. */
|
|
201
|
+
&:--gesture-handler--is-active {
|
|
202
|
+
user-select: none;
|
|
203
|
+
-webkit-user-drag: none;
|
|
204
|
+
transition: none;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|