@jsenv/dom 0.6.0 → 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 +262 -330
- 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 -1491
- package/src/utils.js +0 -69
- package/src/value_effect.js +0 -35
|
@@ -1,635 +0,0 @@
|
|
|
1
|
-
// Keep visual markers (debug markers, obstacle markers, constraint feedback line) in DOM after drag ends
|
|
2
|
-
// Useful for debugging constraint systems and understanding why elements behave certain ways
|
|
3
|
-
// When enabled, markers persist until next drag gesture starts or page is refreshed
|
|
4
|
-
const KEEP_MARKERS_ON_RELEASE = true;
|
|
5
|
-
const MARKER_SIZE = 12;
|
|
6
|
-
|
|
7
|
-
let currentDebugMarkers = [];
|
|
8
|
-
let currentConstraintMarkers = [];
|
|
9
|
-
let currentReferenceElementMarker = null;
|
|
10
|
-
let currentElementMarker = null;
|
|
11
|
-
|
|
12
|
-
export const setupDragDebugMarkers = (dragGesture, { referenceElement }) => {
|
|
13
|
-
// Clean up any existing persistent markers from previous drag gestures
|
|
14
|
-
if (KEEP_MARKERS_ON_RELEASE) {
|
|
15
|
-
// Remove any existing markers from previous gestures
|
|
16
|
-
const container = document.getElementById("navi_debug_markers_container");
|
|
17
|
-
if (container) {
|
|
18
|
-
container.innerHTML = ""; // Clear all markers efficiently
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const { direction, scrollContainer } = dragGesture.gestureInfo;
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
onConstraints: (
|
|
26
|
-
constraints,
|
|
27
|
-
{ left, top, right, bottom, autoScrollArea },
|
|
28
|
-
) => {
|
|
29
|
-
// Schedule removal of previous markers if they exist
|
|
30
|
-
const previousDebugMarkers = [...currentDebugMarkers];
|
|
31
|
-
const previousConstraintMarkers = [...currentConstraintMarkers];
|
|
32
|
-
const previousReferenceElementMarker = currentReferenceElementMarker;
|
|
33
|
-
const previousElementMarker = currentElementMarker;
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
previousDebugMarkers.length > 0 ||
|
|
37
|
-
previousConstraintMarkers.length > 0 ||
|
|
38
|
-
previousReferenceElementMarker ||
|
|
39
|
-
previousElementMarker
|
|
40
|
-
) {
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
previousDebugMarkers.forEach((marker) => marker.remove());
|
|
43
|
-
previousConstraintMarkers.forEach((marker) => marker.remove());
|
|
44
|
-
if (previousReferenceElementMarker) {
|
|
45
|
-
previousReferenceElementMarker.remove();
|
|
46
|
-
}
|
|
47
|
-
if (previousElementMarker) {
|
|
48
|
-
previousElementMarker.remove();
|
|
49
|
-
}
|
|
50
|
-
}, 100);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Clear current marker arrays
|
|
54
|
-
currentDebugMarkers.length = 0;
|
|
55
|
-
currentConstraintMarkers.length = 0;
|
|
56
|
-
currentReferenceElementMarker = null;
|
|
57
|
-
currentElementMarker = null;
|
|
58
|
-
|
|
59
|
-
// Create element marker (always show the dragged element)
|
|
60
|
-
// When there's a reference element, show it as "Dragged Element"
|
|
61
|
-
// When there's no reference element, show it as "Element"
|
|
62
|
-
const elementLabel = referenceElement ? "Dragged Element" : "Element";
|
|
63
|
-
const elementColor = referenceElement ? "255, 0, 150" : "0, 200, 0"; // Pink when with reference, green when standalone
|
|
64
|
-
|
|
65
|
-
currentElementMarker = createElementMarker({
|
|
66
|
-
left,
|
|
67
|
-
top,
|
|
68
|
-
right,
|
|
69
|
-
bottom,
|
|
70
|
-
scrollContainer,
|
|
71
|
-
label: elementLabel,
|
|
72
|
-
color: elementColor,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// Create reference element marker if reference element exists
|
|
76
|
-
if (referenceElement) {
|
|
77
|
-
currentReferenceElementMarker = createReferenceElementMarker({
|
|
78
|
-
left,
|
|
79
|
-
top,
|
|
80
|
-
right,
|
|
81
|
-
bottom,
|
|
82
|
-
scrollContainer,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Collect all markers to be created, then merge duplicates
|
|
87
|
-
const markersToCreate = [];
|
|
88
|
-
|
|
89
|
-
autoscroll_area_markers: {
|
|
90
|
-
if (direction.x) {
|
|
91
|
-
markersToCreate.push({
|
|
92
|
-
name: autoScrollArea.paddingLeft
|
|
93
|
-
? `autoscroll.left + padding(${autoScrollArea.paddingLeft})`
|
|
94
|
-
: "autoscroll.left",
|
|
95
|
-
x: autoScrollArea.left,
|
|
96
|
-
y: 0,
|
|
97
|
-
color: "0 128 0", // green
|
|
98
|
-
side: "left",
|
|
99
|
-
});
|
|
100
|
-
markersToCreate.push({
|
|
101
|
-
name: autoScrollArea.paddingRight
|
|
102
|
-
? `autoscroll.right + padding(${autoScrollArea.paddingRight})`
|
|
103
|
-
: "autoscroll.right",
|
|
104
|
-
x: autoScrollArea.right,
|
|
105
|
-
y: 0,
|
|
106
|
-
color: "0 128 0", // green
|
|
107
|
-
side: "right",
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
if (direction.y) {
|
|
111
|
-
markersToCreate.push({
|
|
112
|
-
name: autoScrollArea.paddingTop
|
|
113
|
-
? `autoscroll.top + padding(${autoScrollArea.paddingTop})`
|
|
114
|
-
: "autoscroll.top",
|
|
115
|
-
x: 0,
|
|
116
|
-
y: autoScrollArea.top,
|
|
117
|
-
color: "255 0 0", // red
|
|
118
|
-
side: "top",
|
|
119
|
-
});
|
|
120
|
-
markersToCreate.push({
|
|
121
|
-
name: autoScrollArea.paddingBottom
|
|
122
|
-
? `autoscroll.bottom + padding(${autoScrollArea.paddingBottom})`
|
|
123
|
-
: "autoscroll.bottom",
|
|
124
|
-
x: 0,
|
|
125
|
-
y: autoScrollArea.bottom,
|
|
126
|
-
color: "255 165 0", // orange
|
|
127
|
-
side: "bottom",
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Process each constraint individually to preserve names
|
|
133
|
-
for (const constraint of constraints) {
|
|
134
|
-
if (constraint.type === "bounds") {
|
|
135
|
-
const { bounds } = constraint;
|
|
136
|
-
|
|
137
|
-
// Create individual markers for each bound with constraint name
|
|
138
|
-
if (direction.x) {
|
|
139
|
-
if (bounds.left !== undefined) {
|
|
140
|
-
markersToCreate.push({
|
|
141
|
-
name: `${constraint.name}.left`,
|
|
142
|
-
x: bounds.left,
|
|
143
|
-
y: 0,
|
|
144
|
-
color: "128 0 128", // purple
|
|
145
|
-
side: "left",
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
if (bounds.right !== undefined) {
|
|
149
|
-
// For visual clarity, show rightBound at the right edge of the element
|
|
150
|
-
// when element is positioned at rightBound (not the left edge position)
|
|
151
|
-
markersToCreate.push({
|
|
152
|
-
name: `${constraint.name}.right`,
|
|
153
|
-
x: bounds.right,
|
|
154
|
-
y: 0,
|
|
155
|
-
color: "128 0 128", // purple
|
|
156
|
-
side: "right",
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (direction.y) {
|
|
161
|
-
if (bounds.top !== undefined) {
|
|
162
|
-
markersToCreate.push({
|
|
163
|
-
name: `${constraint.name}.top`,
|
|
164
|
-
x: 0,
|
|
165
|
-
y: bounds.top,
|
|
166
|
-
color: "128 0 128", // purple
|
|
167
|
-
side: "top",
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
if (bounds.bottom !== undefined) {
|
|
171
|
-
// For visual clarity, show bottomBound at the bottom edge of the element
|
|
172
|
-
// when element is positioned at bottomBound (not the left edge position)
|
|
173
|
-
markersToCreate.push({
|
|
174
|
-
name: `${constraint.name}.bottom`,
|
|
175
|
-
x: 0,
|
|
176
|
-
y: bounds.bottom,
|
|
177
|
-
color: "128 0 128", // purple
|
|
178
|
-
side: "bottom",
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
} else if (constraint.type === "obstacle") {
|
|
183
|
-
const obstacleMarker = createObstacleMarker(
|
|
184
|
-
constraint,
|
|
185
|
-
scrollContainer,
|
|
186
|
-
);
|
|
187
|
-
currentConstraintMarkers.push(obstacleMarker);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Create markers with merging for overlapping positions
|
|
192
|
-
const createdMarkers = createMergedMarkers(
|
|
193
|
-
markersToCreate,
|
|
194
|
-
scrollContainer,
|
|
195
|
-
);
|
|
196
|
-
currentDebugMarkers.push(
|
|
197
|
-
...createdMarkers.filter((m) => m.type !== "constraint"),
|
|
198
|
-
);
|
|
199
|
-
currentConstraintMarkers.push(
|
|
200
|
-
...createdMarkers.filter((m) => m.type === "constraint"),
|
|
201
|
-
);
|
|
202
|
-
},
|
|
203
|
-
onRelease: () => {
|
|
204
|
-
if (KEEP_MARKERS_ON_RELEASE) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
currentDebugMarkers.forEach((marker) => {
|
|
209
|
-
marker.remove();
|
|
210
|
-
});
|
|
211
|
-
currentConstraintMarkers.forEach((marker) => {
|
|
212
|
-
marker.remove();
|
|
213
|
-
});
|
|
214
|
-
if (currentReferenceElementMarker) {
|
|
215
|
-
currentReferenceElementMarker.remove();
|
|
216
|
-
}
|
|
217
|
-
if (currentElementMarker) {
|
|
218
|
-
currentElementMarker.remove();
|
|
219
|
-
}
|
|
220
|
-
currentDebugMarkers = [];
|
|
221
|
-
currentConstraintMarkers = [];
|
|
222
|
-
currentReferenceElementMarker = null;
|
|
223
|
-
currentElementMarker = null;
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
// Ensure markers container exists and return it
|
|
229
|
-
const getMarkersContainer = () => {
|
|
230
|
-
let container = document.getElementById("navi_debug_markers_container");
|
|
231
|
-
if (!container) {
|
|
232
|
-
container = document.createElement("div");
|
|
233
|
-
container.id = "navi_debug_markers_container";
|
|
234
|
-
container.className = "navi_debug_markers_container";
|
|
235
|
-
document.body.appendChild(container);
|
|
236
|
-
}
|
|
237
|
-
return container;
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
// Convert document-relative coordinates to viewport coordinates for marker positioning
|
|
241
|
-
// Takes the scroll container into account for proper positioning relative to the container
|
|
242
|
-
const getDebugMarkerPos = (x, y, scrollContainer, side = null) => {
|
|
243
|
-
const { documentElement } = document;
|
|
244
|
-
|
|
245
|
-
const leftWithoutScroll = x - scrollContainer.scrollLeft;
|
|
246
|
-
const topWithoutScroll = y - scrollContainer.scrollTop;
|
|
247
|
-
let baseX;
|
|
248
|
-
let baseY;
|
|
249
|
-
if (scrollContainer === documentElement) {
|
|
250
|
-
// our markers are injected into the document so we have the right coordinates already
|
|
251
|
-
// and we remove scroll because our markers are in a fixed position ancestor (to ensure they cannot influence scrollbars)
|
|
252
|
-
baseX = leftWithoutScroll;
|
|
253
|
-
baseY = topWithoutScroll;
|
|
254
|
-
} else {
|
|
255
|
-
// we need to remove the scroll of the container?
|
|
256
|
-
// not sure I think here we might want to keep the scroll container scroll
|
|
257
|
-
// and that's it
|
|
258
|
-
const scrollContainerRect = scrollContainer.getBoundingClientRect();
|
|
259
|
-
baseX = scrollContainerRect.left + leftWithoutScroll;
|
|
260
|
-
baseY = scrollContainerRect.top + topWithoutScroll;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// Apply side-specific logic for extending markers across viewport
|
|
264
|
-
if (side === "left" || side === "right") {
|
|
265
|
-
// Vertical markers: x should stay fixed in viewport, y can extend
|
|
266
|
-
return [baseX, 0]; // y=0 to start from top of viewport
|
|
267
|
-
}
|
|
268
|
-
if (side === "top" || side === "bottom") {
|
|
269
|
-
// Horizontal markers: y should stay fixed in viewport, x can extend
|
|
270
|
-
return [0, baseY]; // x=0 to start from left of viewport
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// For obstacles and other markers: use converted coordinates directly
|
|
274
|
-
return [baseX, baseY];
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
const createMergedMarkers = (markersToCreate, scrollContainer) => {
|
|
278
|
-
const mergedMarkers = [];
|
|
279
|
-
const positionMap = new Map();
|
|
280
|
-
|
|
281
|
-
// Group markers by position and side
|
|
282
|
-
for (const marker of markersToCreate) {
|
|
283
|
-
const key = `${marker.x},${marker.y},${marker.side}`;
|
|
284
|
-
|
|
285
|
-
if (!positionMap.has(key)) {
|
|
286
|
-
positionMap.set(key, []);
|
|
287
|
-
}
|
|
288
|
-
positionMap.get(key).push(marker);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// Create markers with merged labels for overlapping positions
|
|
292
|
-
for (const [, markers] of positionMap) {
|
|
293
|
-
if (markers.length === 1) {
|
|
294
|
-
// Single marker - create as normal
|
|
295
|
-
const marker = markers[0];
|
|
296
|
-
const domMarker = createDebugMarker(marker, scrollContainer);
|
|
297
|
-
domMarker.type = marker.name.includes("Bound") ? "constraint" : "visible";
|
|
298
|
-
mergedMarkers.push(domMarker);
|
|
299
|
-
} else {
|
|
300
|
-
// Multiple markers at same position - merge labels
|
|
301
|
-
const firstMarker = markers[0];
|
|
302
|
-
const combinedName = markers.map((m) => m.name).join(" + ");
|
|
303
|
-
|
|
304
|
-
// Use the first marker's color, or mix colors if needed
|
|
305
|
-
const domMarker = createDebugMarker(
|
|
306
|
-
{
|
|
307
|
-
...firstMarker,
|
|
308
|
-
name: combinedName,
|
|
309
|
-
},
|
|
310
|
-
scrollContainer,
|
|
311
|
-
);
|
|
312
|
-
domMarker.type = markers.some((m) => m.name.includes("Bound"))
|
|
313
|
-
? "constraint"
|
|
314
|
-
: "visible";
|
|
315
|
-
mergedMarkers.push(domMarker);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return mergedMarkers;
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
const createDebugMarker = (
|
|
323
|
-
{ name, x, y, color = "255 0 0", side },
|
|
324
|
-
scrollContainer,
|
|
325
|
-
) => {
|
|
326
|
-
// Convert coordinates from document-relative to viewport
|
|
327
|
-
const [viewportX, viewportY] = getDebugMarkerPos(x, y, scrollContainer, side);
|
|
328
|
-
|
|
329
|
-
const marker = document.createElement("div");
|
|
330
|
-
marker.className = `navi_debug_marker`;
|
|
331
|
-
marker.setAttribute(`data-${side}`, "");
|
|
332
|
-
// Set the color as a CSS custom property
|
|
333
|
-
marker.style.setProperty("--marker-color", `rgb(${color})`);
|
|
334
|
-
// Position markers exactly at the boundary coordinates
|
|
335
|
-
marker.style.left =
|
|
336
|
-
side === "right" ? `${viewportX - MARKER_SIZE}px` : `${viewportX}px`;
|
|
337
|
-
marker.style.top =
|
|
338
|
-
side === "bottom" ? `${viewportY - MARKER_SIZE}px` : `${viewportY}px`;
|
|
339
|
-
marker.title = name;
|
|
340
|
-
|
|
341
|
-
// Add label
|
|
342
|
-
const label = document.createElement("div");
|
|
343
|
-
label.className = `navi_debug_marker_label`;
|
|
344
|
-
label.textContent = name;
|
|
345
|
-
marker.appendChild(label);
|
|
346
|
-
|
|
347
|
-
const container = getMarkersContainer();
|
|
348
|
-
container.appendChild(marker);
|
|
349
|
-
return marker;
|
|
350
|
-
};
|
|
351
|
-
const createObstacleMarker = (obstacleObj, scrollContainer) => {
|
|
352
|
-
const width = obstacleObj.bounds.right - obstacleObj.bounds.left;
|
|
353
|
-
const height = obstacleObj.bounds.bottom - obstacleObj.bounds.top;
|
|
354
|
-
|
|
355
|
-
// Convert document-relative coordinates to viewport coordinates
|
|
356
|
-
const [x, y] = getDebugMarkerPos(
|
|
357
|
-
obstacleObj.bounds.left,
|
|
358
|
-
obstacleObj.bounds.top,
|
|
359
|
-
scrollContainer,
|
|
360
|
-
"obstacle",
|
|
361
|
-
);
|
|
362
|
-
|
|
363
|
-
const marker = document.createElement("div");
|
|
364
|
-
marker.className = "navi_obstacle_marker";
|
|
365
|
-
marker.style.left = `${x}px`;
|
|
366
|
-
marker.style.top = `${y}px`;
|
|
367
|
-
marker.style.width = `${width}px`;
|
|
368
|
-
marker.style.height = `${height}px`;
|
|
369
|
-
marker.title = obstacleObj.name;
|
|
370
|
-
|
|
371
|
-
// Add label
|
|
372
|
-
const label = document.createElement("div");
|
|
373
|
-
label.className = "navi_obstacle_marker_label";
|
|
374
|
-
label.textContent = obstacleObj.name;
|
|
375
|
-
marker.appendChild(label);
|
|
376
|
-
|
|
377
|
-
const container = getMarkersContainer();
|
|
378
|
-
container.appendChild(marker);
|
|
379
|
-
return marker;
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
const createElementMarker = ({
|
|
383
|
-
left,
|
|
384
|
-
top,
|
|
385
|
-
right,
|
|
386
|
-
bottom,
|
|
387
|
-
scrollContainer,
|
|
388
|
-
label = "Element",
|
|
389
|
-
color = "0, 200, 0", // Default green color
|
|
390
|
-
}) => {
|
|
391
|
-
const width = right - left;
|
|
392
|
-
const height = bottom - top;
|
|
393
|
-
// Convert document-relative coordinates to viewport coordinates
|
|
394
|
-
const [x, y] = getDebugMarkerPos(left, top, scrollContainer, "element");
|
|
395
|
-
|
|
396
|
-
const marker = document.createElement("div");
|
|
397
|
-
marker.className = "navi_element_marker";
|
|
398
|
-
marker.style.left = `${x}px`;
|
|
399
|
-
marker.style.top = `${y}px`;
|
|
400
|
-
marker.style.width = `${width}px`;
|
|
401
|
-
marker.style.height = `${height}px`;
|
|
402
|
-
marker.title = label;
|
|
403
|
-
|
|
404
|
-
// Set the color as CSS custom properties
|
|
405
|
-
marker.style.setProperty("--element-color", `rgb(${color})`);
|
|
406
|
-
marker.style.setProperty("--element-color-alpha", `rgba(${color}, 0.3)`);
|
|
407
|
-
|
|
408
|
-
// Add label
|
|
409
|
-
const labelEl = document.createElement("div");
|
|
410
|
-
labelEl.className = "navi_element_marker_label";
|
|
411
|
-
labelEl.textContent = label;
|
|
412
|
-
marker.appendChild(labelEl);
|
|
413
|
-
|
|
414
|
-
const container = getMarkersContainer();
|
|
415
|
-
container.appendChild(marker);
|
|
416
|
-
return marker;
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
const createReferenceElementMarker = ({
|
|
420
|
-
left,
|
|
421
|
-
top,
|
|
422
|
-
right,
|
|
423
|
-
bottom,
|
|
424
|
-
scrollContainer,
|
|
425
|
-
}) => {
|
|
426
|
-
const width = right - left;
|
|
427
|
-
const height = bottom - top;
|
|
428
|
-
// Convert document-relative coordinates to viewport coordinates
|
|
429
|
-
const [x, y] = getDebugMarkerPos(left, top, scrollContainer, "reference");
|
|
430
|
-
|
|
431
|
-
const marker = document.createElement("div");
|
|
432
|
-
marker.className = "navi_reference_element_marker";
|
|
433
|
-
marker.style.left = `${x}px`;
|
|
434
|
-
marker.style.top = `${y}px`;
|
|
435
|
-
marker.style.width = `${width}px`;
|
|
436
|
-
marker.style.height = `${height}px`;
|
|
437
|
-
marker.title = "Reference Element";
|
|
438
|
-
|
|
439
|
-
// Add label
|
|
440
|
-
const label = document.createElement("div");
|
|
441
|
-
label.className = "navi_reference_element_marker_label";
|
|
442
|
-
label.textContent = "Reference Element";
|
|
443
|
-
marker.appendChild(label);
|
|
444
|
-
|
|
445
|
-
const container = getMarkersContainer();
|
|
446
|
-
container.appendChild(marker);
|
|
447
|
-
return marker;
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
import.meta.css = /* css */ `
|
|
451
|
-
.navi_debug_markers_container {
|
|
452
|
-
position: fixed;
|
|
453
|
-
top: 0;
|
|
454
|
-
left: 0;
|
|
455
|
-
width: 100vw;
|
|
456
|
-
height: 100vh;
|
|
457
|
-
overflow: hidden;
|
|
458
|
-
pointer-events: none;
|
|
459
|
-
z-index: 999998;
|
|
460
|
-
--marker-size: ${MARKER_SIZE}px;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
.navi_debug_marker {
|
|
464
|
-
position: absolute;
|
|
465
|
-
pointer-events: none;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
/* Markers based on side rather than orientation */
|
|
469
|
-
.navi_debug_marker[data-left],
|
|
470
|
-
.navi_debug_marker[data-right] {
|
|
471
|
-
width: var(--marker-size);
|
|
472
|
-
height: 100vh;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
.navi_debug_marker[data-top],
|
|
476
|
-
.navi_debug_marker[data-bottom] {
|
|
477
|
-
width: 100vw;
|
|
478
|
-
height: var(--marker-size);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
/* Gradient directions based on side, using CSS custom properties for color */
|
|
482
|
-
.navi_debug_marker[data-left] {
|
|
483
|
-
background: linear-gradient(
|
|
484
|
-
to right,
|
|
485
|
-
rgba(from var(--marker-color) r g b / 0.9) 0%,
|
|
486
|
-
rgba(from var(--marker-color) r g b / 0.7) 30%,
|
|
487
|
-
rgba(from var(--marker-color) r g b / 0.3) 70%,
|
|
488
|
-
rgba(from var(--marker-color) r g b / 0) 100%
|
|
489
|
-
);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
.navi_debug_marker[data-right] {
|
|
493
|
-
background: linear-gradient(
|
|
494
|
-
to left,
|
|
495
|
-
rgba(from var(--marker-color) r g b / 0.9) 0%,
|
|
496
|
-
rgba(from var(--marker-color) r g b / 0.7) 30%,
|
|
497
|
-
rgba(from var(--marker-color) r g b / 0.3) 70%,
|
|
498
|
-
rgba(from var(--marker-color) r g b / 0) 100%
|
|
499
|
-
);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
.navi_debug_marker[data-top] {
|
|
503
|
-
background: linear-gradient(
|
|
504
|
-
to bottom,
|
|
505
|
-
rgba(from var(--marker-color) r g b / 0.9) 0%,
|
|
506
|
-
rgba(from var(--marker-color) r g b / 0.7) 30%,
|
|
507
|
-
rgba(from var(--marker-color) r g b / 0.3) 70%,
|
|
508
|
-
rgba(from var(--marker-color) r g b / 0) 100%
|
|
509
|
-
);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
.navi_debug_marker[data-bottom] {
|
|
513
|
-
background: linear-gradient(
|
|
514
|
-
to top,
|
|
515
|
-
rgba(from var(--marker-color) r g b / 0.9) 0%,
|
|
516
|
-
rgba(from var(--marker-color) r g b / 0.7) 30%,
|
|
517
|
-
rgba(from var(--marker-color) r g b / 0.3) 70%,
|
|
518
|
-
rgba(from var(--marker-color) r g b / 0) 100%
|
|
519
|
-
);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
.navi_debug_marker_label {
|
|
523
|
-
position: absolute;
|
|
524
|
-
font-size: 12px;
|
|
525
|
-
font-weight: bold;
|
|
526
|
-
background: rgba(255, 255, 255, 0.9);
|
|
527
|
-
padding: 2px 6px;
|
|
528
|
-
border-radius: 3px;
|
|
529
|
-
border: 1px solid;
|
|
530
|
-
white-space: nowrap;
|
|
531
|
-
pointer-events: none;
|
|
532
|
-
color: rgb(from var(--marker-color) r g b / 1);
|
|
533
|
-
border-color: rgb(from var(--marker-color) r g b / 1);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
/* Label positioning based on side data attributes */
|
|
537
|
-
|
|
538
|
-
/* Left side markers - vertical with 90° rotation */
|
|
539
|
-
.navi_debug_marker[data-left] .navi_debug_marker_label {
|
|
540
|
-
left: 10px;
|
|
541
|
-
top: 20px;
|
|
542
|
-
transform: rotate(90deg);
|
|
543
|
-
transform-origin: left center;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
/* Right side markers - vertical with -90° rotation */
|
|
547
|
-
.navi_debug_marker[data-right] .navi_debug_marker_label {
|
|
548
|
-
right: 10px;
|
|
549
|
-
left: auto;
|
|
550
|
-
top: 20px;
|
|
551
|
-
transform: rotate(-90deg);
|
|
552
|
-
transform-origin: right center;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
/* Top side markers - horizontal, label on the line */
|
|
556
|
-
.navi_debug_marker[data-top] .navi_debug_marker_label {
|
|
557
|
-
top: 0px;
|
|
558
|
-
left: 20px;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/* Bottom side markers - horizontal, label on the line */
|
|
562
|
-
.navi_debug_marker[data-bottom] .navi_debug_marker_label {
|
|
563
|
-
bottom: 0px;
|
|
564
|
-
top: auto;
|
|
565
|
-
left: 20px;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
.navi_obstacle_marker {
|
|
569
|
-
position: absolute;
|
|
570
|
-
background-color: orange;
|
|
571
|
-
opacity: 0.6;
|
|
572
|
-
z-index: 9999;
|
|
573
|
-
pointer-events: none;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
.navi_obstacle_marker_label {
|
|
577
|
-
position: absolute;
|
|
578
|
-
top: 50%;
|
|
579
|
-
left: 50%;
|
|
580
|
-
transform: translate(-50%, -50%);
|
|
581
|
-
font-size: 12px;
|
|
582
|
-
font-weight: bold;
|
|
583
|
-
color: white;
|
|
584
|
-
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
|
|
585
|
-
pointer-events: none;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
.navi_element_marker {
|
|
589
|
-
position: absolute;
|
|
590
|
-
background-color: var(--element-color-alpha, rgba(255, 0, 150, 0.3));
|
|
591
|
-
border: 2px solid var(--element-color, rgb(255, 0, 150));
|
|
592
|
-
opacity: 0.9;
|
|
593
|
-
z-index: 9997;
|
|
594
|
-
pointer-events: none;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
.navi_element_marker_label {
|
|
598
|
-
position: absolute;
|
|
599
|
-
top: -25px;
|
|
600
|
-
right: 0;
|
|
601
|
-
font-size: 11px;
|
|
602
|
-
font-weight: bold;
|
|
603
|
-
color: var(--element-color, rgb(255, 0, 150));
|
|
604
|
-
background: rgba(255, 255, 255, 0.9);
|
|
605
|
-
padding: 2px 6px;
|
|
606
|
-
border-radius: 3px;
|
|
607
|
-
border: 1px solid var(--element-color, rgb(255, 0, 150));
|
|
608
|
-
white-space: nowrap;
|
|
609
|
-
pointer-events: none;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
.navi_reference_element_marker {
|
|
613
|
-
position: absolute;
|
|
614
|
-
background-color: rgba(0, 150, 255, 0.3);
|
|
615
|
-
border: 2px dashed rgba(0, 150, 255, 0.7);
|
|
616
|
-
opacity: 0.8;
|
|
617
|
-
z-index: 9998;
|
|
618
|
-
pointer-events: none;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
.navi_reference_element_marker_label {
|
|
622
|
-
position: absolute;
|
|
623
|
-
top: -25px;
|
|
624
|
-
left: 0;
|
|
625
|
-
font-size: 11px;
|
|
626
|
-
font-weight: bold;
|
|
627
|
-
color: rgba(0, 150, 255, 1);
|
|
628
|
-
background: rgba(255, 255, 255, 0.9);
|
|
629
|
-
padding: 2px 6px;
|
|
630
|
-
border-radius: 3px;
|
|
631
|
-
border: 1px solid rgba(0, 150, 255, 0.7);
|
|
632
|
-
white-space: nowrap;
|
|
633
|
-
pointer-events: none;
|
|
634
|
-
}
|
|
635
|
-
`;
|