@jsenv/dom 0.6.1 → 0.7.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/dist/jsenv_dom.js +259 -314
- package/package.json +2 -4
- package/index.js +0 -124
- package/src/attr/add_attribute_effect.js +0 -93
- package/src/attr/attributes.js +0 -32
- package/src/color/color_constrast.js +0 -69
- package/src/color/color_parsing.js +0 -319
- package/src/color/color_scheme.js +0 -28
- package/src/color/pick_light_or_dark.js +0 -34
- package/src/color/resolve_css_color.js +0 -60
- package/src/demos/3_columns_resize_demo.html +0 -84
- package/src/demos/3_rows_resize_demo.html +0 -89
- package/src/demos/aside_and_main_demo.html +0 -93
- package/src/demos/coordinates_demo.html +0 -450
- package/src/demos/document_autoscroll_demo.html +0 -517
- package/src/demos/drag_gesture_constraints_demo.html +0 -701
- package/src/demos/drag_gesture_demo.html +0 -1047
- package/src/demos/drag_gesture_element_to_impact_demo.html +0 -445
- package/src/demos/drag_reference_element_demo.html +0 -480
- package/src/demos/flex_details_set_demo.html +0 -302
- package/src/demos/flex_details_set_demo_2.html +0 -315
- package/src/demos/visible_rect_demo.html +0 -525
- package/src/element_signature.js +0 -100
- package/src/interaction/drag/constraint_feedback_line.js +0 -92
- package/src/interaction/drag/drag_constraint.js +0 -659
- package/src/interaction/drag/drag_debug_markers.js +0 -635
- package/src/interaction/drag/drag_element_positioner.js +0 -382
- package/src/interaction/drag/drag_gesture.js +0 -566
- package/src/interaction/drag/drag_resize_demo.html +0 -571
- package/src/interaction/drag/drag_to_move.js +0 -301
- package/src/interaction/drag/drag_to_resize_gesture.js +0 -68
- package/src/interaction/drag/drop_target_detection.js +0 -148
- package/src/interaction/drag/sticky_frontiers.js +0 -160
- package/src/interaction/event_marker.js +0 -14
- package/src/interaction/focus/active_element.js +0 -33
- package/src/interaction/focus/arrow_navigation.js +0 -599
- package/src/interaction/focus/element_is_focusable.js +0 -57
- package/src/interaction/focus/element_visibility.js +0 -111
- package/src/interaction/focus/find_focusable.js +0 -21
- package/src/interaction/focus/focus_group.js +0 -91
- package/src/interaction/focus/focus_group_registry.js +0 -12
- package/src/interaction/focus/focus_nav.js +0 -12
- package/src/interaction/focus/focus_nav_event_marker.js +0 -14
- package/src/interaction/focus/focus_trap.js +0 -105
- package/src/interaction/focus/tab_navigation.js +0 -128
- package/src/interaction/focus/tests/focus_group_skip_tab_test.html +0 -206
- package/src/interaction/focus/tests/tree_focus_test.html +0 -304
- package/src/interaction/focus/tests/tree_focus_test.jsx +0 -261
- package/src/interaction/focus/tests/tree_focus_test_preact.html +0 -13
- package/src/interaction/isolate_interactions.js +0 -161
- package/src/interaction/keyboard.js +0 -26
- package/src/interaction/scroll/capture_scroll.js +0 -47
- package/src/interaction/scroll/is_scrollable.js +0 -159
- package/src/interaction/scroll/scroll_container.js +0 -110
- package/src/interaction/scroll/scroll_trap.js +0 -44
- package/src/interaction/scroll/scrollbar_size.js +0 -20
- package/src/interaction/scroll/wheel_through.js +0 -138
- package/src/iterable_weak_set.js +0 -66
- package/src/position/dom_coords.js +0 -340
- package/src/position/offset_parent.js +0 -15
- package/src/position/position_fixed.js +0 -15
- package/src/position/position_sticky.js +0 -213
- package/src/position/sticky_rect.js +0 -79
- package/src/position/visible_rect.js +0 -486
- package/src/pub_sub.js +0 -31
- package/src/size/can_take_size.js +0 -11
- package/src/size/details_content_full_height.js +0 -63
- package/src/size/flex_details_set.js +0 -974
- package/src/size/get_available_height.js +0 -22
- package/src/size/get_available_width.js +0 -22
- package/src/size/get_border_sizes.js +0 -14
- package/src/size/get_height.js +0 -4
- package/src/size/get_inner_height.js +0 -15
- package/src/size/get_inner_width.js +0 -15
- package/src/size/get_margin_sizes.js +0 -10
- package/src/size/get_max_height.js +0 -57
- package/src/size/get_max_width.js +0 -47
- package/src/size/get_min_height.js +0 -14
- package/src/size/get_min_width.js +0 -14
- package/src/size/get_padding_sizes.js +0 -10
- package/src/size/get_width.js +0 -4
- package/src/size/hooks/use_available_height.js +0 -27
- package/src/size/hooks/use_available_width.js +0 -27
- package/src/size/hooks/use_max_height.js +0 -10
- package/src/size/hooks/use_max_width.js +0 -10
- package/src/size/hooks/use_resize_status.js +0 -62
- package/src/size/resize.js +0 -695
- package/src/size/resolve_css_size.js +0 -32
- package/src/style/dom_styles.js +0 -97
- package/src/style/style_composition.js +0 -121
- package/src/style/style_controller.js +0 -345
- package/src/style/style_default.js +0 -153
- package/src/style/style_default_demo.html +0 -128
- package/src/style/style_parsing.js +0 -375
- package/src/transition/demos/animation_resumption_test.xhtml +0 -500
- package/src/transition/demos/height_toggle_test.xhtml +0 -515
- package/src/transition/dom_transition.js +0 -254
- package/src/transition/easing.js +0 -48
- package/src/transition/group_transition.js +0 -261
- package/src/transition/transform_style_parser.js +0 -32
- package/src/transition/transition_playback.js +0 -366
- package/src/transition/transition_timeline.js +0 -79
- package/src/traversal.js +0 -247
- package/src/ui_transition/demos/content_states_transition_demo.html +0 -628
- package/src/ui_transition/demos/smooth_height_transition_demo.html +0 -149
- package/src/ui_transition/demos/transition_testing.html +0 -354
- package/src/ui_transition/ui_transition.js +0 -1470
- package/src/utils.js +0 -69
- package/src/value_effect.js +0 -35
|
@@ -1,480 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Drag Reference Element Demo</title>
|
|
7
|
-
<style>
|
|
8
|
-
body {
|
|
9
|
-
margin: 0;
|
|
10
|
-
padding: 20px;
|
|
11
|
-
font-family: Arial, sans-serif;
|
|
12
|
-
background: #f0f0f0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.demo-section {
|
|
16
|
-
margin: 40px auto;
|
|
17
|
-
max-width: 1000px;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.demo-title {
|
|
21
|
-
background: white;
|
|
22
|
-
padding: 15px 20px;
|
|
23
|
-
border-radius: 8px 8px 0 0;
|
|
24
|
-
border-bottom: 2px solid #333;
|
|
25
|
-
margin: 0;
|
|
26
|
-
font-size: 18px;
|
|
27
|
-
font-weight: bold;
|
|
28
|
-
color: #333;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.demo-container {
|
|
32
|
-
display: flex;
|
|
33
|
-
gap: 20px;
|
|
34
|
-
align-items: flex-start;
|
|
35
|
-
justify-content: center;
|
|
36
|
-
background: white;
|
|
37
|
-
padding: 20px;
|
|
38
|
-
border-radius: 0 0 8px 8px;
|
|
39
|
-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.scroll-container {
|
|
43
|
-
width: 600px;
|
|
44
|
-
height: 400px;
|
|
45
|
-
background: #e8f4fd;
|
|
46
|
-
overflow: auto;
|
|
47
|
-
border: 2px solid #2196f3;
|
|
48
|
-
border-radius: 4px;
|
|
49
|
-
position: relative;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.scroll-content {
|
|
53
|
-
width: 500px;
|
|
54
|
-
height: 400px;
|
|
55
|
-
background:
|
|
56
|
-
linear-gradient(
|
|
57
|
-
90deg,
|
|
58
|
-
transparent 49px,
|
|
59
|
-
#ddd 50px,
|
|
60
|
-
#ddd 51px,
|
|
61
|
-
transparent 52px
|
|
62
|
-
),
|
|
63
|
-
linear-gradient(
|
|
64
|
-
0deg,
|
|
65
|
-
transparent 49px,
|
|
66
|
-
#ddd 50px,
|
|
67
|
-
#ddd 51px,
|
|
68
|
-
transparent 52px
|
|
69
|
-
);
|
|
70
|
-
background-size: 50px 50px;
|
|
71
|
-
position: relative;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.document-area {
|
|
75
|
-
width: 300px;
|
|
76
|
-
height: 200px;
|
|
77
|
-
background: #f8f8f8;
|
|
78
|
-
border: 2px solid #666;
|
|
79
|
-
border-radius: 4px;
|
|
80
|
-
position: relative;
|
|
81
|
-
overflow: visible;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.reference-element {
|
|
85
|
-
width: 60px;
|
|
86
|
-
height: 40px;
|
|
87
|
-
background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
|
|
88
|
-
border: 2px solid #e65100;
|
|
89
|
-
border-radius: 6px;
|
|
90
|
-
position: absolute;
|
|
91
|
-
cursor: pointer;
|
|
92
|
-
display: flex;
|
|
93
|
-
align-items: center;
|
|
94
|
-
justify-content: center;
|
|
95
|
-
color: white;
|
|
96
|
-
font-weight: bold;
|
|
97
|
-
font-size: 10px;
|
|
98
|
-
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
|
|
99
|
-
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
|
|
100
|
-
transition: box-shadow 0.2s ease;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.reference-element:hover {
|
|
104
|
-
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.element-to-move {
|
|
108
|
-
width: 80px;
|
|
109
|
-
height: 60px;
|
|
110
|
-
background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
|
|
111
|
-
border: 2px solid #1b5e20;
|
|
112
|
-
border-radius: 8px;
|
|
113
|
-
position: absolute;
|
|
114
|
-
display: flex;
|
|
115
|
-
align-items: center;
|
|
116
|
-
justify-content: center;
|
|
117
|
-
color: white;
|
|
118
|
-
font-weight: bold;
|
|
119
|
-
font-size: 11px;
|
|
120
|
-
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
|
|
121
|
-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
|
122
|
-
transition: box-shadow 0.2s ease;
|
|
123
|
-
pointer-events: none; /* Only the reference element should be clickable */
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.element-to-move[data-dragging] {
|
|
127
|
-
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
|
|
128
|
-
z-index: 1000;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.info {
|
|
132
|
-
max-width: 1000px;
|
|
133
|
-
margin: 0 auto;
|
|
134
|
-
padding: 20px;
|
|
135
|
-
background: white;
|
|
136
|
-
border-radius: 8px;
|
|
137
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.info h1 {
|
|
141
|
-
margin-top: 0;
|
|
142
|
-
color: #333;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.info ul {
|
|
146
|
-
line-height: 1.6;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.controls {
|
|
150
|
-
background: #f9f9f9;
|
|
151
|
-
padding: 15px;
|
|
152
|
-
border-radius: 6px;
|
|
153
|
-
min-width: 280px;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.controls h4 {
|
|
157
|
-
margin: 0 0 10px 0;
|
|
158
|
-
font-size: 14px;
|
|
159
|
-
color: #333;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.controls button {
|
|
163
|
-
width: 100%;
|
|
164
|
-
padding: 8px 12px;
|
|
165
|
-
margin-bottom: 5px;
|
|
166
|
-
border: none;
|
|
167
|
-
border-radius: 3px;
|
|
168
|
-
cursor: pointer;
|
|
169
|
-
font-size: 12px;
|
|
170
|
-
font-weight: bold;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
.controls button:disabled {
|
|
174
|
-
opacity: 0.5;
|
|
175
|
-
cursor: not-allowed;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.grab-btn {
|
|
179
|
-
background: #4caf50;
|
|
180
|
-
color: white;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
.drag-btn {
|
|
184
|
-
background: #2196f3;
|
|
185
|
-
color: white;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.release-btn {
|
|
189
|
-
background: #f44336;
|
|
190
|
-
color: white;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.status {
|
|
194
|
-
margin-top: 10px;
|
|
195
|
-
padding: 8px;
|
|
196
|
-
background: white;
|
|
197
|
-
border-radius: 3px;
|
|
198
|
-
font-family: monospace;
|
|
199
|
-
font-size: 10px;
|
|
200
|
-
color: #666;
|
|
201
|
-
border: 1px solid #ddd;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
.legend {
|
|
205
|
-
display: flex;
|
|
206
|
-
gap: 20px;
|
|
207
|
-
margin: 15px 0;
|
|
208
|
-
font-size: 12px;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.legend-item {
|
|
212
|
-
display: flex;
|
|
213
|
-
align-items: center;
|
|
214
|
-
gap: 8px;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
.legend-color {
|
|
218
|
-
width: 16px;
|
|
219
|
-
height: 16px;
|
|
220
|
-
border-radius: 3px;
|
|
221
|
-
border: 1px solid #333;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.legend-ref {
|
|
225
|
-
background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.legend-move {
|
|
229
|
-
background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
|
|
230
|
-
}
|
|
231
|
-
</style>
|
|
232
|
-
</head>
|
|
233
|
-
<body>
|
|
234
|
-
<div class="info">
|
|
235
|
-
<h1>Drag Reference Element Demo</h1>
|
|
236
|
-
<p>
|
|
237
|
-
This demo tests drag operations where the
|
|
238
|
-
<strong>reference element</strong> (what you click/drag) is in a
|
|
239
|
-
different positioning context from the <strong>element</strong> (what
|
|
240
|
-
actually moves).
|
|
241
|
-
</p>
|
|
242
|
-
|
|
243
|
-
<div class="legend">
|
|
244
|
-
<div class="legend-item">
|
|
245
|
-
<div class="legend-color legend-ref"></div>
|
|
246
|
-
<span>Reference Element (click to drag)</span>
|
|
247
|
-
</div>
|
|
248
|
-
<div class="legend-item">
|
|
249
|
-
<div class="legend-color legend-move"></div>
|
|
250
|
-
<span>Element (moves when dragging reference)</span>
|
|
251
|
-
</div>
|
|
252
|
-
</div>
|
|
253
|
-
|
|
254
|
-
<p><strong>Test Scenarios:</strong></p>
|
|
255
|
-
<ul>
|
|
256
|
-
<li>
|
|
257
|
-
<strong>Case 1:</strong> Document scroll container, different positioned
|
|
258
|
-
parents - Reference and element share the document as scroll container but
|
|
259
|
-
have different offsetParents
|
|
260
|
-
</li>
|
|
261
|
-
<li>
|
|
262
|
-
<strong>Case 2:</strong> Reference in scroll container, element in document -
|
|
263
|
-
Reference element in custom scroll container, element positioned relative to document
|
|
264
|
-
</li>
|
|
265
|
-
</ul>
|
|
266
|
-
</div>
|
|
267
|
-
|
|
268
|
-
<!-- Case 1: Document scroll container, different positioned parents -->
|
|
269
|
-
<div class="demo-section">
|
|
270
|
-
<h2 class="demo-title">
|
|
271
|
-
Case 1: Document Scroll Container, Different Positioned Parents
|
|
272
|
-
</h2>
|
|
273
|
-
<div class="demo-container">
|
|
274
|
-
<!-- Reference element in a positioned container -->
|
|
275
|
-
<div
|
|
276
|
-
style="
|
|
277
|
-
position: relative;
|
|
278
|
-
top: 20px;
|
|
279
|
-
left: 30px;
|
|
280
|
-
width: 100px;
|
|
281
|
-
height: 80px;
|
|
282
|
-
background: rgba(255, 152, 0, 0.1);
|
|
283
|
-
border: 1px dashed #ff9800;
|
|
284
|
-
"
|
|
285
|
-
>
|
|
286
|
-
<div
|
|
287
|
-
class="reference-element"
|
|
288
|
-
id="case1-ref"
|
|
289
|
-
style="top: 10px; left: 10px"
|
|
290
|
-
>
|
|
291
|
-
REF
|
|
292
|
-
</div>
|
|
293
|
-
</div>
|
|
294
|
-
|
|
295
|
-
<!-- Element in a different positioned container -->
|
|
296
|
-
<div
|
|
297
|
-
style="
|
|
298
|
-
position: relative;
|
|
299
|
-
top: 50px;
|
|
300
|
-
left: 400px;
|
|
301
|
-
width: 120px;
|
|
302
|
-
height: 100px;
|
|
303
|
-
background: rgba(76, 175, 80, 0.1);
|
|
304
|
-
border: 1px dashed #4caf50;
|
|
305
|
-
"
|
|
306
|
-
>
|
|
307
|
-
<div
|
|
308
|
-
class="element-to-move"
|
|
309
|
-
id="case1-element"
|
|
310
|
-
style="top: 20px; left: 20px"
|
|
311
|
-
>
|
|
312
|
-
ELEMENT
|
|
313
|
-
</div>
|
|
314
|
-
</div>
|
|
315
|
-
|
|
316
|
-
<div style="
|
|
317
|
-
background: #f9f9f9;
|
|
318
|
-
padding: 15px;
|
|
319
|
-
border-radius: 6px;
|
|
320
|
-
min-width: 280px;
|
|
321
|
-
">
|
|
322
|
-
<h4 style="margin: 0 0 10px 0; font-size: 14px; color: #333;">Instructions</h4>
|
|
323
|
-
<p style="margin: 0; font-size: 12px; color: #666;">
|
|
324
|
-
Click and drag the orange REF element to move the green ELEMENT.
|
|
325
|
-
Both elements are in the document (same scroll container) but have different positioned parents.
|
|
326
|
-
</p>
|
|
327
|
-
</div>
|
|
328
|
-
</div>
|
|
329
|
-
</div>
|
|
330
|
-
Drag Down
|
|
331
|
-
</button>
|
|
332
|
-
<button class="release-btn" id="case1-release" disabled>
|
|
333
|
-
Release
|
|
334
|
-
</button>
|
|
335
|
-
<div class="status" id="case1-status">
|
|
336
|
-
Ready - Click orange REF to drag green ELEMENT (same scroll,
|
|
337
|
-
different parents)
|
|
338
|
-
</div>
|
|
339
|
-
</div>
|
|
340
|
-
</div>
|
|
341
|
-
</div>
|
|
342
|
-
|
|
343
|
-
<!-- Case 2: Reference in scroll container, element in document -->
|
|
344
|
-
<div class="demo-section">
|
|
345
|
-
<h2 class="demo-title">
|
|
346
|
-
Case 2: Reference in Scroll Container, Element in Document
|
|
347
|
-
</h2>
|
|
348
|
-
<div class="demo-container">
|
|
349
|
-
<!-- Reference element in scroll container -->
|
|
350
|
-
<div class="scroll-container" id="case2-ref-scroll">
|
|
351
|
-
<div class="scroll-content">
|
|
352
|
-
<div
|
|
353
|
-
style="
|
|
354
|
-
position: relative;
|
|
355
|
-
top: 40px;
|
|
356
|
-
left: 80px;
|
|
357
|
-
width: 100px;
|
|
358
|
-
height: 80px;
|
|
359
|
-
background: rgba(255, 152, 0, 0.1);
|
|
360
|
-
border: 1px dashed #ff9800;
|
|
361
|
-
"
|
|
362
|
-
>
|
|
363
|
-
<div
|
|
364
|
-
class="reference-element"
|
|
365
|
-
id="case2-ref"
|
|
366
|
-
style="top: 15px; left: 15px"
|
|
367
|
-
>
|
|
368
|
-
REF
|
|
369
|
-
</div>
|
|
370
|
-
</div>
|
|
371
|
-
</div>
|
|
372
|
-
</div>
|
|
373
|
-
|
|
374
|
-
<!-- Element in document -->
|
|
375
|
-
<div
|
|
376
|
-
style="
|
|
377
|
-
position: relative;
|
|
378
|
-
top: 60px;
|
|
379
|
-
left: 120px;
|
|
380
|
-
width: 120px;
|
|
381
|
-
height: 100px;
|
|
382
|
-
background: rgba(76, 175, 80, 0.1);
|
|
383
|
-
border: 1px dashed #4caf50;
|
|
384
|
-
"
|
|
385
|
-
>
|
|
386
|
-
<div
|
|
387
|
-
class="element-to-move"
|
|
388
|
-
id="case2-element"
|
|
389
|
-
style="top: 25px; left: 25px"
|
|
390
|
-
>
|
|
391
|
-
ELEMENT
|
|
392
|
-
</div>
|
|
393
|
-
</div>
|
|
394
|
-
|
|
395
|
-
<div style="
|
|
396
|
-
background: #f9f9f9;
|
|
397
|
-
padding: 15px;
|
|
398
|
-
border-radius: 6px;
|
|
399
|
-
min-width: 280px;
|
|
400
|
-
">
|
|
401
|
-
<h4 style="margin: 0 0 10px 0; font-size: 14px; color: #333;">Instructions</h4>
|
|
402
|
-
<p style="margin: 0; font-size: 12px; color: #666;">
|
|
403
|
-
Click and drag the orange REF element (in scroll container) to move the green ELEMENT (in document).
|
|
404
|
-
Tests cross-coordinate system drag operation.
|
|
405
|
-
</p>
|
|
406
|
-
</div>
|
|
407
|
-
</div>
|
|
408
|
-
</div>
|
|
409
|
-
</div>
|
|
410
|
-
|
|
411
|
-
<script type="module">
|
|
412
|
-
import { createDragToMoveGestureController } from "@jsenv/dom";
|
|
413
|
-
|
|
414
|
-
// Case configurations
|
|
415
|
-
const cases = [
|
|
416
|
-
{
|
|
417
|
-
id: "case1",
|
|
418
|
-
label: "Doc Diff Parents",
|
|
419
|
-
referenceElement: document.getElementById("case1-ref"),
|
|
420
|
-
element: document.getElementById("case1-element"),
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
id: "case2",
|
|
424
|
-
label: "Scroll → Doc",
|
|
425
|
-
referenceElement: document.getElementById("case2-ref"),
|
|
426
|
-
element: document.getElementById("case2-element"),
|
|
427
|
-
},
|
|
428
|
-
];
|
|
429
|
-
|
|
430
|
-
function setupCase(caseConfig) {
|
|
431
|
-
const { label, referenceElement, element } = caseConfig;
|
|
432
|
-
|
|
433
|
-
// Create drag gesture controller
|
|
434
|
-
const createController = () => {
|
|
435
|
-
return createDragToMoveGestureController({
|
|
436
|
-
backdrop: false,
|
|
437
|
-
onGrab: () => {
|
|
438
|
-
console.log(`${label} - Grabbed`);
|
|
439
|
-
element.setAttribute("data-dragging", "");
|
|
440
|
-
},
|
|
441
|
-
onDragStart: () => {
|
|
442
|
-
console.log(`${label} - Drag started`);
|
|
443
|
-
},
|
|
444
|
-
onDrag: (gestureInfo, phase) => {
|
|
445
|
-
console.log(`${label} - Dragging (${phase})`);
|
|
446
|
-
},
|
|
447
|
-
onRelease: () => {
|
|
448
|
-
console.log(`${label} - Released`);
|
|
449
|
-
element.removeAttribute("data-dragging");
|
|
450
|
-
},
|
|
451
|
-
});
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
// Mouse drag setup
|
|
455
|
-
referenceElement.addEventListener("mousedown", (event) => {
|
|
456
|
-
event.preventDefault();
|
|
457
|
-
|
|
458
|
-
const dragGestureController = createController();
|
|
459
|
-
dragGestureController.grabViaMouse(event, {
|
|
460
|
-
element,
|
|
461
|
-
referenceElement,
|
|
462
|
-
});
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
// Setup all cases
|
|
467
|
-
cases.forEach(setupCase);
|
|
468
|
-
|
|
469
|
-
// Add some initial scroll to containers for testing
|
|
470
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
471
|
-
const case2RefScroll = document.getElementById("case2-ref-scroll");
|
|
472
|
-
|
|
473
|
-
if (case2RefScroll) {
|
|
474
|
-
case2RefScroll.scrollLeft = 30;
|
|
475
|
-
case2RefScroll.scrollTop = 20;
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
</script>
|
|
479
|
-
</body>
|
|
480
|
-
</html>
|