@molecule/app-pointer-events-dom 0.0.0-stage → 0.0.1-stage
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/LICENSE +202 -0
- package/README.md +142 -2
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/web-drag.d.ts +54 -0
- package/dist/web-drag.d.ts.map +1 -0
- package/dist/web-drag.js +225 -0
- package/dist/web-drag.js.map +1 -0
- package/package.json +50 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,143 @@
|
|
|
1
|
-
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-11-25T14:48:10.019Z
|
|
7
|
+
-->
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
# @molecule/app-pointer-events-dom
|
|
10
|
+
|
|
11
|
+
DOM pointer drag gestures for the Molecule web UI kits.
|
|
12
|
+
|
|
13
|
+
Use the renderer's drag binding with `ElementDrag` from `@molecule/app-ui`.
|
|
14
|
+
All web kits share press ownership, pointer capture, touch intent, and
|
|
15
|
+
cancellation on pointer cancel, lost capture, window blur, and host removal.
|
|
16
|
+
Use `markPressTarget` for custom controls that must keep their own presses.
|
|
17
|
+
|
|
18
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
19
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
20
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { bindWebDrag } from '@molecule/app-pointer-events-dom'
|
|
26
|
+
|
|
27
|
+
const host = document.querySelector<HTMLElement>('[data-mol-id="drag-handle"]')
|
|
28
|
+
if (host) {
|
|
29
|
+
const binding = bindWebDrag(host, { onStart: (point) => console.log(point.x) })
|
|
30
|
+
// Call binding.update(handlers) on updates and binding.destroy() on unmount.
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Type
|
|
35
|
+
|
|
36
|
+
`utility`
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install @molecule/app-pointer-events-dom @molecule/app-ui
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
### Interfaces
|
|
47
|
+
|
|
48
|
+
#### `WebDrag`
|
|
49
|
+
|
|
50
|
+
The renderer-facing controls for one drag host.
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
interface WebDrag {
|
|
54
|
+
/**
|
|
55
|
+
* Updates the callbacks used by the gesture. Removing the handlers cancels the contact.
|
|
56
|
+
*
|
|
57
|
+
* @param drag - The current handlers, or undefined to disable dragging.
|
|
58
|
+
*/
|
|
59
|
+
update(drag: ElementDrag | undefined): void
|
|
60
|
+
/**
|
|
61
|
+
* Offers a pointer press to this host.
|
|
62
|
+
*
|
|
63
|
+
* @param host - The element receiving the press.
|
|
64
|
+
* @param down - The native pointer event shared by all hosts.
|
|
65
|
+
* @param drag - The press settings, when supplied by a renderer's event binding.
|
|
66
|
+
* @param target - The renderer's normalized target, when it differs from the native target.
|
|
67
|
+
*/
|
|
68
|
+
start(
|
|
69
|
+
host: HTMLElement | SVGElement,
|
|
70
|
+
down: PointerEvent,
|
|
71
|
+
drag?: ElementDrag,
|
|
72
|
+
target?: EventTarget | null,
|
|
73
|
+
): void
|
|
74
|
+
/** Cancels the active contact, if any. */
|
|
75
|
+
cancel(): void
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### `WebDragBinding`
|
|
80
|
+
|
|
81
|
+
The lifecycle of a drag attached to a DOM element.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
interface WebDragBinding {
|
|
85
|
+
/**
|
|
86
|
+
* Updates the handlers for this host.
|
|
87
|
+
*
|
|
88
|
+
* @param drag - The current handlers, or undefined to disable dragging.
|
|
89
|
+
*/
|
|
90
|
+
update(drag: ElementDrag | undefined): void
|
|
91
|
+
/** Removes the pointer listener and cancels any active contact. */
|
|
92
|
+
destroy(): void
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Functions
|
|
97
|
+
|
|
98
|
+
#### `markPressTarget(host)`
|
|
99
|
+
|
|
100
|
+
Marks a custom press target so an enclosing drag leaves its activation alone.
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
function markPressTarget(host: Element): void
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- `host` — The element that owns the activation.
|
|
107
|
+
|
|
108
|
+
#### `createWebDrag(initialDrag)`
|
|
109
|
+
|
|
110
|
+
Acquires a press on the deepest drag host and follows its pointer until release or interruption.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
function createWebDrag(initialDrag?: ElementDrag): WebDrag
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- `initialDrag` — The initial handlers, if the host starts enabled.
|
|
117
|
+
|
|
118
|
+
**Returns:** The controls a renderer uses to handle pointerdown, updates and unmount.
|
|
119
|
+
|
|
120
|
+
#### `bindWebDrag(host, drag)`
|
|
121
|
+
|
|
122
|
+
Binds a drag to a native bubbling pointerdown listener.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
function bindWebDrag(host: HTMLElement | SVGElement, drag?: ElementDrag): WebDragBinding
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- `host` — The element that can own the press.
|
|
129
|
+
- `drag` — The initial handlers, if the host starts enabled.
|
|
130
|
+
|
|
131
|
+
**Returns:** The binding to update or destroy with the host.
|
|
132
|
+
|
|
133
|
+
## Injection Notes
|
|
134
|
+
|
|
135
|
+
### Requirements
|
|
136
|
+
|
|
137
|
+
Peer dependencies:
|
|
138
|
+
|
|
139
|
+
- `@molecule/app-ui` ^1.9.0
|
|
140
|
+
|
|
141
|
+
### Runtime Dependencies
|
|
142
|
+
|
|
143
|
+
- `@molecule/app-ui`
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM pointer drag gestures for the Molecule web UI kits.
|
|
3
|
+
*
|
|
4
|
+
* Use the renderer's drag binding with `ElementDrag` from `@molecule/app-ui`.
|
|
5
|
+
* All web kits share press ownership, pointer capture, touch intent, and
|
|
6
|
+
* cancellation on pointer cancel, lost capture, window blur, and host removal.
|
|
7
|
+
* Use `markPressTarget` for custom controls that must keep their own presses.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { bindWebDrag } from '@molecule/app-pointer-events-dom'
|
|
12
|
+
*
|
|
13
|
+
* const host = document.querySelector<HTMLElement>('[data-mol-id="drag-handle"]')
|
|
14
|
+
* if (host) {
|
|
15
|
+
* const binding = bindWebDrag(host, { onStart: (point) => console.log(point.x) })
|
|
16
|
+
* // Call binding.update(handlers) on updates and binding.destroy() on unmount.
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
export * from './web-drag.js';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,cAAc,eAAe,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM pointer drag gestures for the Molecule web UI kits.
|
|
3
|
+
*
|
|
4
|
+
* Use the renderer's drag binding with `ElementDrag` from `@molecule/app-ui`.
|
|
5
|
+
* All web kits share press ownership, pointer capture, touch intent, and
|
|
6
|
+
* cancellation on pointer cancel, lost capture, window blur, and host removal.
|
|
7
|
+
* Use `markPressTarget` for custom controls that must keep their own presses.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { bindWebDrag } from '@molecule/app-pointer-events-dom'
|
|
12
|
+
*
|
|
13
|
+
* const host = document.querySelector<HTMLElement>('[data-mol-id="drag-handle"]')
|
|
14
|
+
* if (host) {
|
|
15
|
+
* const binding = bindWebDrag(host, { onStart: (point) => console.log(point.x) })
|
|
16
|
+
* // Call binding.update(handlers) on updates and binding.destroy() on unmount.
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
export * from './web-drag.js';
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,cAAc,eAAe,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ElementDrag } from '@molecule/app-ui';
|
|
2
|
+
/**
|
|
3
|
+
* Marks a custom press target so an enclosing drag leaves its activation alone.
|
|
4
|
+
*
|
|
5
|
+
* @param host - The element that owns the activation.
|
|
6
|
+
*/
|
|
7
|
+
export declare function markPressTarget(host: Element): void;
|
|
8
|
+
/** The renderer-facing controls for one drag host. */
|
|
9
|
+
export interface WebDrag {
|
|
10
|
+
/**
|
|
11
|
+
* Updates the callbacks used by the gesture. Removing the handlers cancels the contact.
|
|
12
|
+
*
|
|
13
|
+
* @param drag - The current handlers, or undefined to disable dragging.
|
|
14
|
+
*/
|
|
15
|
+
update(drag: ElementDrag | undefined): void;
|
|
16
|
+
/**
|
|
17
|
+
* Offers a pointer press to this host.
|
|
18
|
+
*
|
|
19
|
+
* @param host - The element receiving the press.
|
|
20
|
+
* @param down - The native pointer event shared by all hosts.
|
|
21
|
+
* @param drag - The press settings, when supplied by a renderer's event binding.
|
|
22
|
+
* @param target - The renderer's normalized target, when it differs from the native target.
|
|
23
|
+
*/
|
|
24
|
+
start(host: HTMLElement | SVGElement, down: PointerEvent, drag?: ElementDrag, target?: EventTarget | null): void;
|
|
25
|
+
/** Cancels the active contact, if any. */
|
|
26
|
+
cancel(): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Acquires a press on the deepest drag host and follows its pointer until release or interruption.
|
|
30
|
+
*
|
|
31
|
+
* @param initialDrag - The initial handlers, if the host starts enabled.
|
|
32
|
+
* @returns The controls a renderer uses to handle pointerdown, updates and unmount.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createWebDrag(initialDrag?: ElementDrag): WebDrag;
|
|
35
|
+
/** The lifecycle of a drag attached to a DOM element. */
|
|
36
|
+
export interface WebDragBinding {
|
|
37
|
+
/**
|
|
38
|
+
* Updates the handlers for this host.
|
|
39
|
+
*
|
|
40
|
+
* @param drag - The current handlers, or undefined to disable dragging.
|
|
41
|
+
*/
|
|
42
|
+
update(drag: ElementDrag | undefined): void;
|
|
43
|
+
/** Removes the pointer listener and cancels any active contact. */
|
|
44
|
+
destroy(): void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Binds a drag to a native bubbling pointerdown listener.
|
|
48
|
+
*
|
|
49
|
+
* @param host - The element that can own the press.
|
|
50
|
+
* @param drag - The initial handlers, if the host starts enabled.
|
|
51
|
+
* @returns The binding to update or destroy with the host.
|
|
52
|
+
*/
|
|
53
|
+
export declare function bindWebDrag(host: HTMLElement | SVGElement, drag?: ElementDrag): WebDragBinding;
|
|
54
|
+
//# sourceMappingURL=web-drag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-drag.d.ts","sourceRoot":"","sources":["../src/web-drag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,kBAAkB,CAAA;AAQrE;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAEnD;AA6CD,sDAAsD;AACtD,MAAM,WAAW,OAAO;IACtB;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAAA;IAC3C;;;;;;;OAOG;IACH,KAAK,CACH,IAAI,EAAE,WAAW,GAAG,UAAU,EAC9B,IAAI,EAAE,YAAY,EAClB,IAAI,CAAC,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GAC1B,IAAI,CAAA;IACP,0CAA0C;IAC1C,MAAM,IAAI,IAAI,CAAA;CACf;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAgJhE;AAED,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAAA;IAC3C,mEAAmE;IACnE,OAAO,IAAI,IAAI,CAAA;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,cAAc,CAY9F"}
|
package/dist/web-drag.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
const claimed = new WeakSet();
|
|
2
|
+
const pressTargets = new WeakSet();
|
|
3
|
+
const controls = 'button, input, textarea, select, label, a[href], [role="button"], [role="link"]';
|
|
4
|
+
const LONG_PRESS_MS = 500;
|
|
5
|
+
const TOUCH_SLOP = 8;
|
|
6
|
+
/**
|
|
7
|
+
* Marks a custom press target so an enclosing drag leaves its activation alone.
|
|
8
|
+
*
|
|
9
|
+
* @param host - The element that owns the activation.
|
|
10
|
+
*/
|
|
11
|
+
export function markPressTarget(host) {
|
|
12
|
+
pressTargets.add(host);
|
|
13
|
+
}
|
|
14
|
+
/** Finds a descendant control that owns the interaction. */
|
|
15
|
+
function insideControl(host, target) {
|
|
16
|
+
const ownerWindow = host.ownerDocument.defaultView;
|
|
17
|
+
if (!ownerWindow || !(target instanceof ownerWindow.Element) || !host.contains(target)) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
for (let child = target; child && child !== host; child = child.parentElement) {
|
|
21
|
+
if (pressTargets.has(child) ||
|
|
22
|
+
child.matches(controls) ||
|
|
23
|
+
(child instanceof ownerWindow.HTMLElement && child.isContentEditable) ||
|
|
24
|
+
child.matches('[contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"]')) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
/** Builds a sample from the current viewport while retaining the original contact position. */
|
|
31
|
+
function point(viewport, down, { clientX, clientY, altKey, ctrlKey, metaKey, shiftKey }) {
|
|
32
|
+
const { left, top, width, height } = viewport.getBoundingClientRect();
|
|
33
|
+
return {
|
|
34
|
+
x: clientX - left,
|
|
35
|
+
y: clientY - top,
|
|
36
|
+
dx: clientX - down.clientX,
|
|
37
|
+
dy: clientY - down.clientY,
|
|
38
|
+
bounds: { x: left, y: top, width, height },
|
|
39
|
+
altKey,
|
|
40
|
+
ctrlKey,
|
|
41
|
+
metaKey,
|
|
42
|
+
shiftKey,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Acquires a press on the deepest drag host and follows its pointer until release or interruption.
|
|
47
|
+
*
|
|
48
|
+
* @param initialDrag - The initial handlers, if the host starts enabled.
|
|
49
|
+
* @returns The controls a renderer uses to handle pointerdown, updates and unmount.
|
|
50
|
+
*/
|
|
51
|
+
export function createWebDrag(initialDrag) {
|
|
52
|
+
let handlers = initialDrag;
|
|
53
|
+
let active = null;
|
|
54
|
+
/**
|
|
55
|
+
* Claims the press and starts tracking the owning pointer.
|
|
56
|
+
*
|
|
57
|
+
* @param host - The host receiving the press.
|
|
58
|
+
* @param down - The native pointer event.
|
|
59
|
+
* @param drag - The settings at the time of the press.
|
|
60
|
+
* @param target - The element the press hit.
|
|
61
|
+
*/
|
|
62
|
+
function start(host, down, drag = handlers, target = down.target) {
|
|
63
|
+
if (!drag)
|
|
64
|
+
return;
|
|
65
|
+
if (down.button !== undefined && down.button !== 0)
|
|
66
|
+
return;
|
|
67
|
+
// A pointer event can lack a device type when dispatched through a mouse-only host.
|
|
68
|
+
if (down.pointerType && down.isPrimary === false)
|
|
69
|
+
return;
|
|
70
|
+
if (claimed.has(down) || insideControl(host, target))
|
|
71
|
+
return;
|
|
72
|
+
const ownerWindow = host.ownerDocument.defaultView;
|
|
73
|
+
if (!ownerWindow)
|
|
74
|
+
return;
|
|
75
|
+
claimed.add(down);
|
|
76
|
+
const { pointerId } = down;
|
|
77
|
+
// A down for the same pointer after a lost terminal event starts a new contact.
|
|
78
|
+
if (active && active.pointerId !== pointerId)
|
|
79
|
+
return;
|
|
80
|
+
active?.cancel();
|
|
81
|
+
const viewport = host.localName === 'g' && 'ownerSVGElement' in host ? (host.ownerSVGElement ?? host) : host;
|
|
82
|
+
const touch = down.pointerType === 'touch';
|
|
83
|
+
const longPress = touch && drag.touchStart === 'longPress';
|
|
84
|
+
let timer;
|
|
85
|
+
let last;
|
|
86
|
+
let captured = false;
|
|
87
|
+
let axisChosen = longPress ||
|
|
88
|
+
(drag.axis !== 'horizontal' && drag.axis !== 'vertical') ||
|
|
89
|
+
(touch && ownerWindow.getComputedStyle(host).touchAction === 'none');
|
|
90
|
+
const session = { pointerId, cancel: () => finish() };
|
|
91
|
+
active = session;
|
|
92
|
+
/** Captures the contact when supported and delivers the first sample. */
|
|
93
|
+
function acquire() {
|
|
94
|
+
if (active !== session)
|
|
95
|
+
return;
|
|
96
|
+
if (host.setPointerCapture && Number.isFinite(pointerId)) {
|
|
97
|
+
try {
|
|
98
|
+
host.setPointerCapture(pointerId);
|
|
99
|
+
captured = true;
|
|
100
|
+
}
|
|
101
|
+
catch (_error) {
|
|
102
|
+
// A browser may reject capture for a contact it no longer tracks. The window listens too.
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
last = point(viewport, down, down);
|
|
106
|
+
handlers?.onStart(last);
|
|
107
|
+
}
|
|
108
|
+
/** Lets an ordinary swipe reach a scroller while touch intent remains undetermined. */
|
|
109
|
+
function shouldYield(x, y) {
|
|
110
|
+
if (!touch || (last && axisChosen))
|
|
111
|
+
return false;
|
|
112
|
+
const dx = Math.abs(x - down.clientX);
|
|
113
|
+
const dy = Math.abs(y - down.clientY);
|
|
114
|
+
if (Math.max(dx, dy) <= TOUCH_SLOP)
|
|
115
|
+
return false;
|
|
116
|
+
if (!last)
|
|
117
|
+
return true;
|
|
118
|
+
axisChosen = true;
|
|
119
|
+
return drag?.axis === 'horizontal' ? dy > dx : dx > dy;
|
|
120
|
+
}
|
|
121
|
+
/** Delivers movement from the owned pointer after scroll negotiation. */
|
|
122
|
+
function move(sample) {
|
|
123
|
+
if (sample.pointerId !== pointerId)
|
|
124
|
+
return;
|
|
125
|
+
if (shouldYield(sample.clientX, sample.clientY))
|
|
126
|
+
finish();
|
|
127
|
+
else if (last) {
|
|
128
|
+
last = point(viewport, down, sample);
|
|
129
|
+
handlers?.onMove?.(last);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** Reserves a touch already acquired by this gesture. */
|
|
133
|
+
function preventScroll(event) {
|
|
134
|
+
const contact = event.touches[0];
|
|
135
|
+
if (event.touches.length !== 1 || !contact)
|
|
136
|
+
return;
|
|
137
|
+
if (shouldYield(contact.clientX, contact.clientY))
|
|
138
|
+
finish();
|
|
139
|
+
else if (last && axisChosen && event.cancelable)
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
}
|
|
142
|
+
/** Releases only when the owning pointer lifts. */
|
|
143
|
+
function up(sample) {
|
|
144
|
+
if (sample.pointerId === pointerId)
|
|
145
|
+
finish(sample);
|
|
146
|
+
}
|
|
147
|
+
/** Handles cancellation and lost capture for the owning pointer. */
|
|
148
|
+
function cancel(sample) {
|
|
149
|
+
const id = 'pointerId' in sample ? sample.pointerId : undefined;
|
|
150
|
+
if (id === pointerId)
|
|
151
|
+
finish();
|
|
152
|
+
}
|
|
153
|
+
/** Removes the active subscriptions before the single terminal callback. */
|
|
154
|
+
function finish(released) {
|
|
155
|
+
if (active !== session)
|
|
156
|
+
return;
|
|
157
|
+
active = null;
|
|
158
|
+
clearTimeout(timer);
|
|
159
|
+
ownerWindow?.removeEventListener('pointermove', move, true);
|
|
160
|
+
ownerWindow?.removeEventListener('pointerup', up, true);
|
|
161
|
+
ownerWindow?.removeEventListener('pointercancel', cancel, true);
|
|
162
|
+
ownerWindow?.removeEventListener('touchmove', preventScroll);
|
|
163
|
+
ownerWindow?.removeEventListener('blur', session.cancel);
|
|
164
|
+
host.removeEventListener('lostpointercapture', cancel);
|
|
165
|
+
if (captured && host.releasePointerCapture) {
|
|
166
|
+
try {
|
|
167
|
+
host.releasePointerCapture(pointerId);
|
|
168
|
+
}
|
|
169
|
+
catch (_error) {
|
|
170
|
+
// The browser can release capture before notifying us of cancellation or removal.
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (!last)
|
|
174
|
+
return;
|
|
175
|
+
if (released)
|
|
176
|
+
handlers?.onEnd?.(point(viewport, down, released));
|
|
177
|
+
else
|
|
178
|
+
handlers?.onCancel?.(last);
|
|
179
|
+
}
|
|
180
|
+
// Captured events bubble here too, so the fallback and the captured stream share one listener.
|
|
181
|
+
ownerWindow.addEventListener('pointermove', move, true);
|
|
182
|
+
ownerWindow.addEventListener('pointerup', up, true);
|
|
183
|
+
ownerWindow.addEventListener('pointercancel', cancel, true);
|
|
184
|
+
ownerWindow.addEventListener('blur', session.cancel);
|
|
185
|
+
host.addEventListener('lostpointercapture', cancel);
|
|
186
|
+
if (touch)
|
|
187
|
+
ownerWindow.addEventListener('touchmove', preventScroll, { passive: false });
|
|
188
|
+
if (longPress)
|
|
189
|
+
timer = setTimeout(acquire, LONG_PRESS_MS);
|
|
190
|
+
else
|
|
191
|
+
acquire();
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
start,
|
|
195
|
+
update(drag) {
|
|
196
|
+
if (!drag)
|
|
197
|
+
active?.cancel();
|
|
198
|
+
handlers = drag;
|
|
199
|
+
},
|
|
200
|
+
cancel() {
|
|
201
|
+
active?.cancel();
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Binds a drag to a native bubbling pointerdown listener.
|
|
207
|
+
*
|
|
208
|
+
* @param host - The element that can own the press.
|
|
209
|
+
* @param drag - The initial handlers, if the host starts enabled.
|
|
210
|
+
* @returns The binding to update or destroy with the host.
|
|
211
|
+
*/
|
|
212
|
+
export function bindWebDrag(host, drag) {
|
|
213
|
+
const gesture = createWebDrag(drag);
|
|
214
|
+
const target = host;
|
|
215
|
+
const pointerDown = (event) => gesture.start(host, event);
|
|
216
|
+
target.addEventListener('pointerdown', pointerDown);
|
|
217
|
+
return {
|
|
218
|
+
update: gesture.update,
|
|
219
|
+
destroy() {
|
|
220
|
+
target.removeEventListener('pointerdown', pointerDown);
|
|
221
|
+
gesture.cancel();
|
|
222
|
+
},
|
|
223
|
+
};
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AM,EAAE,CAAA;YAC3B,QAAQ,GAAG,IAAI,CAAA;QACjB,CAAC;QACD,MAAM;YACJ,MAAM,EAAE,MAAM,EAAE,CAAA;QAClB,CAAC;KACF,CAAA;AACH,CAAC;AAcD;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,IAA8B,EAAE,IAAkB;IAC5E,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,MAAM,GAAwB,IAAI,CAAA;IACxC,MAAM,WAAW,GAAG,CAAC,KAAmB,EAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC7E,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;IACnD,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO;YACL,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;YACtD,OAAO,CAAC,MAAM,EAAE,CAAA;QAClB,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-pointer-events-dom",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1-stage",
|
|
4
|
+
"description": "DOM pointer event handling shared by Molecule web UI kits",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"test": "vitest run"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"molecule",
|
|
24
|
+
"pointer",
|
|
25
|
+
"drag",
|
|
26
|
+
"dom"
|
|
27
|
+
],
|
|
28
|
+
"license": "Apache-2.0",
|
|
29
|
+
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@molecule/app-ui": "^1.9.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@molecule/app-ui": "1.9.0",
|
|
35
|
+
"@types/node": "26.6.5",
|
|
36
|
+
"jsdom": "31.0.1",
|
|
37
|
+
"typescript": "6.0.3",
|
|
38
|
+
"vitest": "4.1.12"
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
43
|
+
"directory": "packages/app/utilities/pointer-events-dom"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://www.molecule.dev/packages/app-pointer-events-dom",
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/molecule-dev/molecule/issues"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
52
|
+
}
|